From 601a0de46a932909fb10f9c9ef48a3ffb4039953 Mon Sep 17 00:00:00 2001 From: minsu4107 <32637512+minsu4107@users.noreply.github.com> Date: Fri, 19 Jun 2020 23:37:47 +0900 Subject: [PATCH] This program has several mode and making these. When making these mode, find suitable mode using flag. So, i test this functions. --- .../qrcodegen/testQrSegmentAdvanced.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/java/src/main/java/io/nayuki/qrcodegen/testQrSegmentAdvanced.java b/java/src/main/java/io/nayuki/qrcodegen/testQrSegmentAdvanced.java index 75266fa..4f9b0e6 100644 --- a/java/src/main/java/io/nayuki/qrcodegen/testQrSegmentAdvanced.java +++ b/java/src/main/java/io/nayuki/qrcodegen/testQrSegmentAdvanced.java @@ -71,4 +71,32 @@ public class testQrSegmentAdvanced { testing.makeSegmentsOptimally(nullstring, Ecc.LOW, 1, 40); } + /** + *Purpose: This program has several mode and making these. When making these mode, find suitable mode using flag. So, i test this functions. + * is_numeric -> 0 ~ 9 's UTF-8 number, is_alphanumeric -> "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:" stinrg set, + *Input: "0123456780", "A", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:" + *Expected: + * All is correct + */ + @Test + public void is_Corredt_Mode_test() { + int[] correctStr = "09".codePoints().toArray(); + for (int forcnt : correctStr){ + assertEquals(QrSegmentAdvanced.is_numeric(forcnt), true); + } + int[] wrongStr = "a".codePoints().toArray(); + for (int forcnt : wrongStr){ + assertEquals(QrSegmentAdvanced.is_numeric(forcnt), false); + } + + correctStr = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".codePoints().toArray(); + for (int forcnt : correctStr){ + assertEquals(QrSegmentAdvanced.is_alphanumeric(forcnt), true); + } + + wrongStr = "\\".codePoints().toArray(); + for (int forcnt : wrongStr){ + assertEquals(QrSegmentAdvanced.is_alphanumeric(forcnt), false); + } + } }