classdef test_IFCmonths < matlab.unittest.TestCase methods(TestClassSetup) % Shared setup for the entire test class end methods(TestMethodSetup) % Setup for each test end methods(Test) % Test methods function test_jan1(testCase) [nMonths, nDays, leaped, yeared] = IFCmonths(1, 2000); testCase.verifyEqual(nMonths, uint8(1)); testCase.verifyEqual(nDays, uint8(1)); testCase.verifyFalse(leaped); testCase.verifyFalse(yeared); end function test_jan31(testCase) [nMonths, nDays, leaped, yeared] = IFCmonths(31, 2000); testCase.verifyEqual(nMonths, uint8(2)); testCase.verifyEqual(nDays, uint8(3)); testCase.verifyFalse(leaped); testCase.verifyFalse(yeared); end function test_jun17_leap(testCase) [nMonths, nDays, leaped, yeared] = IFCmonths(168, 2000); testCase.verifyEqual(nMonths, uint8(6)); testCase.verifyEqual(nDays, uint8(28)); testCase.verifyFalse(leaped); testCase.verifyFalse(yeared); end function test_jun17_noleap(testCase) [nMonths, nDays, leaped, yeared] = IFCmonths(168, 2001); testCase.verifyEqual(nMonths, uint8(6)); testCase.verifyEqual(nDays, uint8(28)); testCase.verifyFalse(leaped); testCase.verifyFalse(yeared); end function test_jun18_leap(testCase) [nMonths, nDays, leaped, yeared] = IFCmonths(169, 2000); testCase.verifyEqual(nMonths, uint8(14)); testCase.verifyEqual(nDays, uint8(0)); testCase.verifyTrue(leaped); testCase.verifyFalse(yeared); end function test_jun18_noleap(testCase) [nMonths, nDays, leaped, yeared] = IFCmonths(169, 2001); testCase.verifyEqual(nMonths, uint8(7)); testCase.verifyEqual(nDays, uint8(1)); testCase.verifyFalse(leaped); testCase.verifyFalse(yeared); end function test_dec31_noleap(testCase) [nMonths, nDays, leaped, yeared] = IFCmonths(365, 2001); testCase.verifyEqual(nMonths, uint8(14)); testCase.verifyEqual(nDays, uint8(0)); testCase.verifyFalse(leaped); testCase.verifyTrue(yeared); end function test_dec31_leap(testCase) [nMonths, nDays, leaped, yeared] = IFCmonths(366, 2000); testCase.verifyEqual(nMonths, uint8(14)); testCase.verifyEqual(nDays, uint8(0)); testCase.verifyTrue(leaped); testCase.verifyTrue(yeared); end function test_today(testCase) [nMonths, nDays, leaped, yeared] = IFCmonths(363, 2024); testCase.verifyEqual(nMonths, uint8(13)); testCase.verifyEqual(nDays, uint8(26)); testCase.verifyTrue(leaped); testCase.verifyFalse(yeared); end function test_vectorized(testCase) [nMonths, nDays, leaped, yeared] = IFCmonths([1; 31; 168; 168; 169; 169; 365; 366; 363], [2000; 2000; 2000; 2001; 2000; 2001; 2001; 2000; 2024]); testCase.verifyEqual(nMonths, uint8([1; 2; 6; 6; 14; 7; 14; 14; 13])); testCase.verifyEqual(nDays, uint8([1; 3; 28; 28; 0; 1; 0; 0; 26])); testCase.verifyEqual(leaped, [false; false; false; false; true; false; false; true; true]); testCase.verifyEqual(yeared, [false; false; false; false; false; false; true; true; false]); end end end