63 lines
2.4 KiB
Matlab
63 lines
2.4 KiB
Matlab
classdef test_IFC < 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_today(testCase)
|
|
ifc = IFC(datetime('28-Dec-2024'));
|
|
testCase.verifyEqual(ifc.Year, uint16(2024));
|
|
testCase.verifyEqual(ifc.Month, MONTHS(13));
|
|
testCase.verifyEqual(ifc.Day, uint8(26));
|
|
testCase.verifyEqual(ifc.DayOfWeek, DAYSOFWEEK(5));
|
|
end
|
|
|
|
function test_yearday_noleap(testCase)
|
|
ifc = IFC(datetime('31-Dec-2023'));
|
|
testCase.verifyEqual(ifc.Year, uint16(2023));
|
|
testCase.verifyEqual(ifc.Month, MONTHS(14));
|
|
testCase.verifyEqual(ifc.Day, uint8(0));
|
|
testCase.verifyEqual(ifc.DayOfWeek, DAYSOFWEEK(7));
|
|
end
|
|
|
|
function test_yearday_leap(testCase)
|
|
ifc = IFC(datetime('31-Dec-2020'));
|
|
testCase.verifyEqual(ifc.Year, uint16(2020));
|
|
testCase.verifyEqual(ifc.Month, MONTHS(14));
|
|
testCase.verifyEqual(ifc.Day, uint8(0));
|
|
testCase.verifyEqual(ifc.DayOfWeek, DAYSOFWEEK(7));
|
|
end
|
|
|
|
function test_leapday_noleap(testCase)
|
|
ifc = IFC(datetime('17-Jun-2003'));
|
|
testCase.verifyEqual(ifc.Year, uint16(2003));
|
|
testCase.verifyEqual(ifc.Month, MONTHS(6));
|
|
testCase.verifyEqual(ifc.Day, uint8(28));
|
|
testCase.verifyEqual(ifc.DayOfWeek, DAYSOFWEEK(0));
|
|
end
|
|
|
|
function test_leapday_leap(testCase)
|
|
ifc = IFC(datetime('17-Jun-2008'));
|
|
testCase.verifyEqual(ifc.Year, uint16(2008));
|
|
testCase.verifyEqual(ifc.Month, MONTHS(14));
|
|
testCase.verifyEqual(ifc.Day, uint8(0));
|
|
testCase.verifyEqual(ifc.DayOfWeek, DAYSOFWEEK(8));
|
|
end
|
|
|
|
function test_all_vectorized(testCase)
|
|
ifc = IFC(datetime(["28-Dec-2024"; "31-Dec-2023"; "31-Dec-2020"; "17-Jun-2003"; "17-Jun-2008"]));
|
|
testCase.verifyEqual([ifc.Year], uint16([2024; 2023; 2020; 2003; 2008]));
|
|
testCase.verifyEqual([ifc.Month], MONTHS([13; 14; 14; 6; 14]));
|
|
testCase.verifyEqual([ifc.Day], uint8([26; 0; 0; 28; 0]));
|
|
testCase.verifyEqual([ifc.DayOfWeek], DAYSOFWEEK([5; 7; 7; 0; 8]));
|
|
end
|
|
end
|
|
|
|
end |