11&if 1 =0 &then
22/* ***********************************************
3- Copyright (c) 2022 by Progress Software Corporation. All rights reserved.
3+ Copyright (c) 2022,2023 by Progress Software Corporation. All rights reserved.
44*************************************************/
55/* * ------------------------------------------------------------------------
66 File : OpenEdge/Core/Assertion/assertequality.i
@@ -53,7 +53,23 @@ Copyright (c) 2022 by Progress Software Corporation. All rights reserved.
5353
5454 // If sizes are equals then compare contents by use of hashing
5555 if message-digest(" SHA-256 " , a) ne message-digest(" SHA-256 " , b) then
56- return error new AssertionFailedError(" Hashes of memptr values are not equal" , 0).
56+ return error new AssertionFailedError(" Hashes of memptr values are not equal" :u, 0).
57+ &elseif " {&Datatype}" eq " raw" &then
58+ // Use a simpler error message as raw values cannot be output directly.
59+ if not (a eq b) then
60+ return error new AssertionFailedError(" Raw values are not equal" :u, 0).
61+ &elseif " {&Datatype}" eq " character" &then
62+ if not (a eq b) then do:
63+ if (length(a) + length(b)) ge 30000 then
64+ // Use a simpler error message to avoid errors from too-long substitutions.
65+ return error new AssertionFailedError(" Character values are not equal" :u, 0).
66+ else
67+ return error new AssertionFailedError(substitute(subMessage, a, b), 0).
68+ end.
69+ &elseif " {&Datatype}" eq " longchar" &then
70+ // Always use a simpler error message to avoid errors from too-long substitutions.
71+ if not (a eq b) then
72+ return error new AssertionFailedError(" Longchar values are not equal" :u, 0).
5773 &else
5874 if not (a eq b) then
5975 return error new AssertionFailedError(substitute(subMessage, a, b), 0).
@@ -75,7 +91,23 @@ Copyright (c) 2022 by Progress Software Corporation. All rights reserved.
7591 &elseif " {&Datatype}" eq " memptr" &then
7692 // If both size and contents (hashes) match then values are considered equal.
7793 if get-size(a) eq get-size(b) and message-digest(" SHA-256 " , a) eq message-digest(" SHA-256 " , b) then
78- return error new AssertionFailedError(substitute(subMessage, " Hash of ' a' " , " hash of ' b' " ), 0).
94+ return error new AssertionFailedError(substitute(subMessage, " Hash of ' a' " :u, " hash of ' b' " :u), 0).
95+ &elseif " {&Datatype}" eq " raw" &then
96+ // Use a simpler error message as raw values cannot be output directly.
97+ if a eq b then
98+ return error new AssertionFailedError(" Raw values are equal" :u, 0).
99+ &elseif " {&Datatype}" eq " character" &then
100+ if a eq b then do:
101+ if (length(a) + length(b)) ge 30000 then
102+ // Use a simpler error message to avoid errors from too-long substitutions.
103+ return error new AssertionFailedError(" Character values are equal" :u, 0).
104+ else
105+ return error new AssertionFailedError(substitute(subMessage, a, b), 0).
106+ end.
107+ &elseif " {&Datatype}" eq " longchar" &then
108+ // Always use a simpler error message to avoid errors from too-long substitutions.
109+ if a eq b then
110+ return error new AssertionFailedError(" Longchar values are equal" :u, 0).
79111 &else
80112 if a eq b then
81113 return error new AssertionFailedError(substitute(subMessage, a, b), 0).
0 commit comments