|
| 1 | +import { describe, expect, it } from '@jest/globals'; |
| 2 | +import { logger as console } from '../../../logger'; |
| 3 | + |
| 4 | +import { |
| 5 | + whatFlavors, |
| 6 | + what_flavors_bruteforce_compute |
| 7 | +} from './ctci_ice_cream_parlor_bruteforce'; |
| 8 | +import TEST_CASES from './ctci_ice_cream_parlor.testcases.json'; |
| 9 | +import TEST_CASES_BORDER_CASES from './ctci_ice_cream_parlor.border_testcases.json'; |
| 10 | + |
| 11 | +describe('ctci_ice_cream_parlor_bruteforce', () => { |
| 12 | + it('whatFlavors test cases', () => { |
| 13 | + expect.assertions(10); |
| 14 | + |
| 15 | + TEST_CASES.forEach((testSet) => { |
| 16 | + testSet?.tests.forEach((test) => { |
| 17 | + const answer = what_flavors_bruteforce_compute(test.costs, test.money); |
| 18 | + |
| 19 | + console.debug( |
| 20 | + `${testSet.title} ctci_ice_cream_parlor_bruteforce(${test.costs}, ${test.money}) solution found: ${answer}` |
| 21 | + ); |
| 22 | + |
| 23 | + expect(answer).toStrictEqual(test.expected); |
| 24 | + expect(whatFlavors(test.costs, test.money)).toBeUndefined(); |
| 25 | + }); |
| 26 | + }); |
| 27 | + }); |
| 28 | + |
| 29 | + it('whatFlavors border test cases', () => { |
| 30 | + expect.assertions(2); |
| 31 | + |
| 32 | + TEST_CASES_BORDER_CASES.forEach((testSet) => { |
| 33 | + testSet?.tests.forEach((test) => { |
| 34 | + expect( |
| 35 | + what_flavors_bruteforce_compute(test.costs, test.money) |
| 36 | + ).toStrictEqual(test.expected); |
| 37 | + expect(whatFlavors(test.costs, test.money)).toBeUndefined(); |
| 38 | + }); |
| 39 | + }); |
| 40 | + }); |
| 41 | + |
| 42 | + it('whatFlavors test caller function', () => { |
| 43 | + expect.assertions(1); |
| 44 | + |
| 45 | + const cost: number[] = []; |
| 46 | + const money: number = 100; |
| 47 | + |
| 48 | + expect(whatFlavors(cost, money)).toBeUndefined(); |
| 49 | + }); |
| 50 | +}); |
0 commit comments