Skip to content

Commit

Permalink
#102 Add tests for potential field size issue
Browse files Browse the repository at this point in the history
  • Loading branch information
yruslan committed Jun 14, 2019
1 parent 4bcbc32 commit 5b13381
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class DataSizeSpec extends FunSuite {
assert(CopybookParser.expandPic("X(3)XXX") == "XXXXXX")
assert(CopybookParser.expandPic("X(3)XX(5)X") == "XXXXXXXXXX")
assert(CopybookParser.expandPic("XX(3)X.X(5)X") == "XXXXX.XXXXXX")
assert(CopybookParser.expandPic("S9(9)V9(6)") == "S999999999V999999")
assert(CopybookParser.expandPic("S9(15)V9(2)") == "S999999999999999V99")
assert(CopybookParser.expandPic("S9(15)V99") == "S999999999999999V99")
}

test("Test Number of Decimal digits are reported correctly for a given PIC") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class FieldSizeSpec extends FunSuite {
| 10 DECIMAL-NUM2 PIC S9(09)V99 BINARY.
| 10 LONG_LEAD_SIG1 PIC S9(9) SIGN LEADING SEPARATE.
| 10 DECIMAL_LEAD_SIG1 PIC S9(9)V99 SIGN LEADING SEPARATE.
| 10 TWO_SETS_BRACES PIC S9(15)V99.
| 10 TWO_SETS_BRACES2 PIC S9(15)V9(2).
|""".stripMargin

def fieldsize(index: Int, cpy: Copybook): Int = {
Expand All @@ -54,6 +56,8 @@ class FieldSizeSpec extends FunSuite {
val size_s9_11_v_binary = fieldsize(5, copybook)
val size_s9_long_sign_leading_separate = fieldsize(6, copybook)
val size_s11_decimal_sign_leading_separate = fieldsize(7, copybook)
val two_sets_braces = fieldsize(8, copybook)
val two_sets_braces2 = fieldsize(9, copybook)

assert(size_s9_2_comp == 2)
assert(size_x10 == 10)
Expand All @@ -63,5 +67,7 @@ class FieldSizeSpec extends FunSuite {
assert(size_s9_11_v_binary == 8)
assert(size_s9_long_sign_leading_separate == 10)
assert(size_s11_decimal_sign_leading_separate == 12)
assert(two_sets_braces == 17)
assert(two_sets_braces2 == 17)
}
}

0 comments on commit 5b13381

Please sign in to comment.