REFACTOR: organize tests into groups and add edge cases
This commit is contained in:
parent
5bf2839e33
commit
5dfc85fc20
1 changed files with 62 additions and 72 deletions
|
|
@ -1,80 +1,70 @@
|
||||||
import 'package:tdd_katas/roman_numerals.dart' as roman_numerals;
|
import 'package:tdd_katas/roman_numerals.dart';
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
test('converts 1 to I', () {
|
group('Roman Numerals Conversion', () {
|
||||||
expect(roman_numerals.integerToRoman(1), 'I');
|
group('Basic Symbols', () {
|
||||||
|
test('smallest unit', () => expect(integerToRoman(1), 'I'));
|
||||||
|
test('five', () => expect(integerToRoman(5), 'V'));
|
||||||
|
test('ten', () => expect(integerToRoman(10), 'X'));
|
||||||
|
test('fifty', () => expect(integerToRoman(50), 'L'));
|
||||||
|
test('hundred', () => expect(integerToRoman(100), 'C'));
|
||||||
|
test('five hundred', () => expect(integerToRoman(500), 'D'));
|
||||||
|
test('thousand', () => expect(integerToRoman(1000), 'M'));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('converts 2 to II', () {
|
group('Subtractive Notation', () {
|
||||||
expect(roman_numerals.integerToRoman(2), 'II');
|
test('four (one before five)', () => expect(integerToRoman(4), 'IV'));
|
||||||
|
test('nine (one before ten)', () => expect(integerToRoman(9), 'IX'));
|
||||||
|
test('forty (ten before fifty)', () => expect(integerToRoman(40), 'XL'));
|
||||||
|
test(
|
||||||
|
'ninety (ten before hundred)',
|
||||||
|
() => expect(integerToRoman(90), 'XC'),
|
||||||
|
);
|
||||||
|
test(
|
||||||
|
'four hundred (hundred before five hundred)',
|
||||||
|
() => expect(integerToRoman(400), 'CD'),
|
||||||
|
);
|
||||||
|
test(
|
||||||
|
'nine hundred (hundred before thousand)',
|
||||||
|
() => expect(integerToRoman(900), 'CM'),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('converts 3 to III', () {
|
group('Additive Combinations', () {
|
||||||
expect(roman_numerals.integerToRoman(3), 'III');
|
test('two (repeated symbol)', () => expect(integerToRoman(2), 'II'));
|
||||||
|
test(
|
||||||
|
'three (maximum repetition)',
|
||||||
|
() => expect(integerToRoman(3), 'III'),
|
||||||
|
);
|
||||||
|
test('six (additive after five)', () => expect(integerToRoman(6), 'VI'));
|
||||||
|
test(
|
||||||
|
'twenty-seven (multiple symbols)',
|
||||||
|
() => expect(integerToRoman(27), 'XXVII'),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('converts 4 to IV', () {
|
group('Complex Edge Cases', () {
|
||||||
expect(roman_numerals.integerToRoman(4), 'IV');
|
test(
|
||||||
|
'forty-nine (combines subtractive symbols)',
|
||||||
|
() => expect(integerToRoman(49), 'XLIX'),
|
||||||
|
);
|
||||||
|
test(
|
||||||
|
'ninety-nine (maximum two-digit complexity)',
|
||||||
|
() => expect(integerToRoman(99), 'XCIX'),
|
||||||
|
);
|
||||||
|
test(
|
||||||
|
'four hundred forty-four (all subtractive positions)',
|
||||||
|
() => expect(integerToRoman(444), 'CDXLIV'),
|
||||||
|
);
|
||||||
|
test(
|
||||||
|
'1994 (year notation stress test)',
|
||||||
|
() => expect(integerToRoman(1994), 'MCMXCIV'),
|
||||||
|
);
|
||||||
|
test(
|
||||||
|
'3999 (maximum valid Roman numeral)',
|
||||||
|
() => expect(integerToRoman(3999), 'MMMCMXCIX'),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('converts 5 to V', () {
|
|
||||||
expect(roman_numerals.integerToRoman(5), 'V');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('converts 6 to VI', () {
|
|
||||||
expect(roman_numerals.integerToRoman(6), 'VI');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('converts 7 to VII', () {
|
|
||||||
expect(roman_numerals.integerToRoman(7), 'VII');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('converts 8 to VIII', () {
|
|
||||||
expect(roman_numerals.integerToRoman(8), 'VIII');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('converts 9 to IX', () {
|
|
||||||
expect(roman_numerals.integerToRoman(9), 'IX');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('converts 10 to X', () {
|
|
||||||
expect(roman_numerals.integerToRoman(10), 'X');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('converts 40 to XL', () {
|
|
||||||
expect(roman_numerals.integerToRoman(40), 'XL');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('converts 49 to XLIX', () {
|
|
||||||
expect(roman_numerals.integerToRoman(49), 'XLIX');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('converts 50 to L', () {
|
|
||||||
expect(roman_numerals.integerToRoman(50), 'L');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('converts 90 to XC', () {
|
|
||||||
expect(roman_numerals.integerToRoman(90), 'XC');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('converts 100 to C', () {
|
|
||||||
expect(roman_numerals.integerToRoman(100), 'C');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('converts 400 to CD', () {
|
|
||||||
expect(roman_numerals.integerToRoman(400), 'CD');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('converts 500 to D', () {
|
|
||||||
expect(roman_numerals.integerToRoman(500), 'D');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('converts 900 to CM', () {
|
|
||||||
expect(roman_numerals.integerToRoman(900), 'CM');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('converts 1000 to M', () {
|
|
||||||
expect(roman_numerals.integerToRoman(1000), 'M');
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue