|
| 1 | +unit TestCases; |
| 2 | + |
| 3 | +{$mode ObjFPC}{$H+} |
| 4 | + |
| 5 | +interface |
| 6 | + |
| 7 | +uses Classes, SysUtils, FPCUnit, TestRegistry, FPCUnitTestUtils; |
| 8 | + |
| 9 | +type |
| 10 | + MatrixTest = class(TTestCase) |
| 11 | + published |
| 12 | + procedure extract_row_from_one_number_matrix; |
| 13 | + procedure can_extract_row; |
| 14 | + procedure extract_row_where_numbers_have_different_widths; |
| 15 | + procedure can_extract_row_from_non_square_matrix_with_no_corresponding_column; |
| 16 | + procedure extract_column_from_one_number_matrix; |
| 17 | + procedure can_extract_column; |
| 18 | + procedure can_extract_column_from_non_square_matrix_with_no_corresponding_row; |
| 19 | + procedure extract_column_where_numbers_have_different_widths; |
| 20 | + end; |
| 21 | + |
| 22 | +implementation |
| 23 | + |
| 24 | +uses Matrix; |
| 25 | + |
| 26 | +// ca733dab-9d85-4065-9ef6-a880a951dafd |
| 27 | +procedure MatrixTest.extract_row_from_one_number_matrix; |
| 28 | +begin |
| 29 | + TapAssertTrue(Self, 'extract row from one number matrix', [1], Matrix.row('1', 1)); |
| 30 | +end; |
| 31 | + |
| 32 | +// 5c93ec93-80e1-4268-9fc2-63bc7d23385c |
| 33 | +procedure MatrixTest.can_extract_row; |
| 34 | +begin |
| 35 | + TapAssertTrue(Self, 'can extract row', [3, 4], Matrix.row('1 2\n3 4', 2)); |
| 36 | +end; |
| 37 | + |
| 38 | +// 2f1aad89-ad0f-4bd2-9919-99a8bff0305a |
| 39 | +procedure MatrixTest.extract_row_where_numbers_have_different_widths; |
| 40 | +begin |
| 41 | + TapAssertTrue(Self, 'extract row where numbers have different widths', [10, 20], Matrix.row('1 2\n10 20', 2)); |
| 42 | +end; |
| 43 | + |
| 44 | +// 68f7f6ba-57e2-4e87-82d0-ad09889b5204 |
| 45 | +procedure MatrixTest.can_extract_row_from_non_square_matrix_with_no_corresponding_column; |
| 46 | +begin |
| 47 | + TapAssertTrue(Self, 'can extract row from non-square matrix with no corresponding column', [8, 7, 6], Matrix.row('1 2 3\n4 5 6\n7 8 9\n8 7 6', 4)); |
| 48 | +end; |
| 49 | + |
| 50 | +// e8c74391-c93b-4aed-8bfe-f3c9beb89ebb |
| 51 | +procedure MatrixTest.extract_column_from_one_number_matrix; |
| 52 | +begin |
| 53 | + TapAssertTrue(Self, 'extract column from one number matrix', [1], Matrix.column('1', 1)); |
| 54 | +end; |
| 55 | + |
| 56 | +// 7136bdbd-b3dc-48c4-a10c-8230976d3727 |
| 57 | +procedure MatrixTest.can_extract_column; |
| 58 | +begin |
| 59 | + TapAssertTrue(Self, 'can extract column', [3, 6, 9], Matrix.column('1 2 3\n4 5 6\n7 8 9', 3)); |
| 60 | +end; |
| 61 | + |
| 62 | +// ad64f8d7-bba6-4182-8adf-0c14de3d0eca |
| 63 | +procedure MatrixTest.can_extract_column_from_non_square_matrix_with_no_corresponding_row; |
| 64 | +begin |
| 65 | + TapAssertTrue(Self, 'can extract column from non-square matrix with no corresponding row', [4, 8, 6], Matrix.column('1 2 3 4\n5 6 7 8\n9 8 7 6', 4)); |
| 66 | +end; |
| 67 | + |
| 68 | +// 9eddfa5c-8474-440e-ae0a-f018c2a0dd89 |
| 69 | +procedure MatrixTest.extract_column_where_numbers_have_different_widths; |
| 70 | +begin |
| 71 | + TapAssertTrue(Self, 'extract column where numbers have different widths', [1903, 3, 4], Matrix.column('89 1903 3\n18 3 1\n9 4 800', 2)); |
| 72 | +end; |
| 73 | + |
| 74 | +initialization |
| 75 | +RegisterTest(MatrixTest); |
| 76 | + |
| 77 | +end. |
0 commit comments