Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added tests to make sure that expressions like .33 can be parsed as b…
…oth double and strings.
  • Loading branch information
Thomas Kaiser committed Dec 10, 2015
1 parent 850ec39 commit 63a975d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion config/src/test/resources/test01.conf
Expand Up @@ -6,7 +6,9 @@

"floats" : {
"fortyTwoPointOne" : 42.1,
"fortyTwoPointOneAgain" : ${floats.fortyTwoPointOne}
"fortyTwoPointOneAgain" : ${floats.fortyTwoPointOne},
"pointThirtyThree": .33
"pointThirtyThreeAgain": ${floats.pointThirtyThree}
},

"strings" : {
Expand All @@ -18,6 +20,7 @@
"d" : "d",
"concatenated" : null bar 42 baz true 3.14 hi,
"double" : "3.14",
"doubleStartingWithDot": ".33",
"number" : "57",
"null" : "null",
"true" : "true",
Expand Down
Expand Up @@ -565,6 +565,8 @@ class ConfigTest extends TestUtils {
assertEquals(42L, conf.getLong("ints.fortyTwoAgain"))
assertEquals(42.1, conf.getDouble("floats.fortyTwoPointOne"), 1e-6)
assertEquals(42.1, conf.getDouble("floats.fortyTwoPointOneAgain"), 1e-6)
assertEquals(0.33, conf.getDouble("floats.pointThirtyThree"), 1e-6)
assertEquals(0.33, conf.getDouble("floats.pointThirtyThreeAgain"), 1e-6)
assertEquals("abcd", conf.getString("strings.abcd"))
assertEquals("abcd", conf.getString("strings.abcdAgain"))
assertEquals("null bar 42 baz true 3.14 hi", conf.getString("strings.concatenated"))
Expand Down Expand Up @@ -721,10 +723,12 @@ class ConfigTest extends TestUtils {
// should convert numbers to string
assertEquals("42", conf.getString("ints.fortyTwo"))
assertEquals("42.1", conf.getString("floats.fortyTwoPointOne"))
assertEquals(".33", conf.getString("floats.pointThirtyThree"))

// should convert string to number
assertEquals(57, conf.getInt("strings.number"))
assertEquals(3.14, conf.getDouble("strings.double"), 1e-6)
assertEquals(0.33, conf.getDouble("strings.doubleStartingWithDot"), 1e-6)

// should convert strings to boolean
assertEquals(true, conf.getBoolean("strings.true"))
Expand Down

0 comments on commit 63a975d

Please sign in to comment.