From 3b0f4fefe43c483bab3d2d1c3eddfb7dca0fecba Mon Sep 17 00:00:00 2001 From: Sarah Gilmore Date: Wed, 6 Sep 2023 15:12:38 -0400 Subject: [PATCH] Move display unit tests for DateType classes to tDisplay.m --- matlab/test/arrow/type/tDate32Type.m | 22 ---------------------- matlab/test/arrow/type/tDate64Type.m | 22 ---------------------- matlab/test/arrow/type/tDisplay.m | 28 ++++++++++++++++++++++++++-- 3 files changed, 26 insertions(+), 46 deletions(-) diff --git a/matlab/test/arrow/type/tDate32Type.m b/matlab/test/arrow/type/tDate32Type.m index 71a9e5cf48fc6..c486772c455a7 100644 --- a/matlab/test/arrow/type/tDate32Type.m +++ b/matlab/test/arrow/type/tDate32Type.m @@ -40,28 +40,6 @@ function DefaultDateUnit(testCase) testCase.verifyEqual(actualUnit, expectedUnit); end - function Display(testCase) - % Verify the display of Date32Type objects. - % - % Example: - % - % Date32Type with properties: - % - % ID: Date32 - % DateUnit: Day - % - type = testCase.ConstructionFcn(); %#ok - classnameLink = "Date32Type"; - header = " " + classnameLink + " with properties:" + newline; - body = strjust(pad(["ID:"; "DateUnit:"])); - body = body + " " + ["Date32"; "Day"]; - body = " " + body; - footer = string(newline); - expectedDisplay = char(strjoin([header body' footer], newline)); - actualDisplay = evalc('disp(type)'); - testCase.verifyEqual(actualDisplay, expectedDisplay); - end - function DateUnitNoSetter(testCase) % Verify that an error is thrown when trying to set the value % of the DateUnit property. diff --git a/matlab/test/arrow/type/tDate64Type.m b/matlab/test/arrow/type/tDate64Type.m index 9345f6dbde50b..b9e9c3637e9d0 100644 --- a/matlab/test/arrow/type/tDate64Type.m +++ b/matlab/test/arrow/type/tDate64Type.m @@ -40,28 +40,6 @@ function DefaultDateUnit(testCase) testCase.verifyEqual(actualUnit, expectedUnit); end - function Display(testCase) - % Verify the display of Date64Type objects. - % - % Example: - % - % Date32Type with properties: - % - % ID: Date64 - % DateUnit: Millisecond - % - type = testCase.ConstructionFcn(); %#ok - classnameLink = "Date64Type"; - header = " " + classnameLink + " with properties:" + newline; - body = strjust(pad(["ID:"; "DateUnit:"])); - body = body + " " + ["Date64"; "Millisecond"]; - body = " " + body; - footer = string(newline); - expectedDisplay = char(strjoin([header body' footer], newline)); - actualDisplay = evalc('disp(type)'); - testCase.verifyEqual(actualDisplay, expectedDisplay); - end - function DateUnitNoSetter(testCase) % Verify that an error is thrown when trying to set the value % of the DateUnit property. diff --git a/matlab/test/arrow/type/tDisplay.m b/matlab/test/arrow/type/tDisplay.m index 88e1b0b66155a..99560dd402115 100644 --- a/matlab/test/arrow/type/tDisplay.m +++ b/matlab/test/arrow/type/tDisplay.m @@ -148,7 +148,6 @@ function TestTimeType(testCase, TimeType) % % ID: Time32 % TimeUnit: Second - % type = TimeType; fullClassName = string(class(type)); @@ -157,7 +156,32 @@ function TestTimeType(testCase, TimeType) header = " " + typeLink + " with properties:" + newline; body = strjust(pad(["ID:"; "TimeUnit:"])); - body = body + " " + ["Time32"; string(type.TimeUnit)]; + body = body + " " + [string(type.ID); string(type.TimeUnit)]; + body = " " + body; + footer = string(newline); + expectedDisplay = char(strjoin([header body' footer], newline)); + actualDisplay = evalc('disp(type)'); + testCase.verifyEqual(actualDisplay, expectedDisplay); + end + + function TestDateType(testCase, DateType) + % Verify the display of DateType objects. + % + % Example: + % + % Date32Type with properties: + % + % ID: Date32 + % DateUnit: Day + + type = DateType; + fullClassName = string(class(type)); + className = reverse(extractBefore(reverse(fullClassName), ".")); + typeLink = makeLinkString(FullClassName=fullClassName, ClassName=className, BoldFont=true); + + header = " " + typeLink + " with properties:" + newline; + body = strjust(pad(["ID:"; "DateUnit:"])); + body = body + " " + [string(type.ID); string(type.DateUnit)]; body = " " + body; footer = string(newline); expectedDisplay = char(strjoin([header body' footer], newline));