Overview
Comment: | s_expressions-encodings: add a test for the user-defined base-64 charset |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
6236ad7b60a608b1941883248f2668f0 |
User & Date: | nat on 2014-04-14 21:29:40 |
Other Links: | manifest | tags |
Context
2014-04-15
| ||
20:16 | s_expressions-interpreters: add a null command constant that does nothing check-in: c3bac18f66 user: nat tags: trunk | |
2014-04-14
| ||
21:29 | s_expressions-encodings: add a test for the user-defined base-64 charset check-in: 6236ad7b60 user: nat tags: trunk | |
2014-04-13
| ||
17:17 | s_expressions-encodings: add base-64 conversions with custom representations of 62 and 63 check-in: a41d6ed173 user: nat tags: trunk | |
Changes
Modified tests/natools-s_expressions-encodings-tests.adb from [9abe5ffd1c] to [d8ad95a92c].
︙ | |||
20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | + | package body Natools.S_Expressions.Encodings.Tests is procedure All_Tests (Report : in out NT.Reporter'Class) is begin Hexadecimal_Test (Report); Base64_Test (Report); User_Base64_Test (Report); end All_Tests; procedure Hexadecimal_Test (Report : in out NT.Reporter'Class) is All_Octets : Atom (1 .. 256); begin for I in All_Octets'Range loop |
︙ | |||
250 251 252 253 254 255 256 257 | 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | Report.Item (Name, NT.Fail); Report.Info ("Unexpected exception " & Ada.Exceptions.Exception_Name (Error) & " has been raised"); end; end Base64_Test; procedure User_Base64_Test (Report : in out NT.Reporter'Class) is Test : NT.Test := Report.Item ("Base-64 with user-defined charset"); begin declare Digit_62 : constant Octet := Character'Pos ('-'); Digit_63 : constant Octet := Character'Pos ('_'); -- Charset for Base-64 URI (RFC 4648) Padding : constant Octet := Character'Pos ('|'); Source : constant Atom := (4#0000#, 4#0100#, 4#2003#, 4#0100#, 4#1101#, 4#2013#, 4#0200#, 4#2102#, 4#2023#, 4#0300#, 4#3103#, 4#2033#, 4#1001#, 4#0110#, 4#2103#, 4#1101#, 4#1111#, 4#2113#, 4#1201#, 4#2112#, 4#2123#, 4#1301#, 4#3113#, 4#2133#, 4#2002#, 4#0120#, 4#2203#, 4#2102#, 4#1121#, 4#2213#, 4#2202#, 4#2122#, 4#2223#, 4#2302#, 4#3123#, 4#2233#, 4#3003#, 4#0130#, 4#2303#, 4#3103#, 4#1131#, 4#2313#, 4#3203#, 4#2132#, 4#2323#, 4#3303#, 4#3133#, 4#2333#, 16#42#); Expected : constant Atom := (65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, Digit_62, Digit_63, 81, 103, Padding, Padding); Encoded_Short : constant Atom := Encode_Base64 (Source, Digit_62, Digit_63); Encoded_Long : constant Atom := Encode_Base64 (Source, Digit_62, Digit_63, Padding); begin Test_Tools.Test_Atom (Test, Expected, Encoded_Long); Test_Tools.Test_Atom (Test, Expected (Expected'First .. Expected'Last - 2), Encoded_Short); Test_Tools.Test_Atom (Test, Source, Decode_Base64 (Encoded_Long, Digit_62, Digit_63)); Test_Tools.Test_Atom (Test, Source, Decode_Base64 (Encoded_Short, Digit_62, Digit_63)); end; exception when Error : others => Test.Report_Exception (Error); end User_Base64_Test; end Natools.S_Expressions.Encodings.Tests; |
Modified tests/natools-s_expressions-encodings-tests.ads from [bccbfc67e5] to [688230bad6].
︙ | |||
27 28 29 30 31 32 33 34 35 36 | 27 28 29 30 31 32 33 34 35 36 37 | + | package NT renames Natools.Tests; procedure All_Tests (Report : in out NT.Reporter'Class); -- Run all available tests procedure Hexadecimal_Test (Report : in out NT.Reporter'Class); procedure Base64_Test (Report : in out NT.Reporter'Class); procedure User_Base64_Test (Report : in out NT.Reporter'Class); -- Run test suite for each encoding type end Natools.S_Expressions.Encodings.Tests; |