add test for numeric -> string conversions
authorLouis Brandy <ldbrandy@fb.com>
Fri, 27 Sep 2013 17:02:51 +0000 (10:02 -0700)
committerPeter Griess <pgriess@fb.com>
Tue, 15 Oct 2013 01:44:04 +0000 (18:44 -0700)
Summary: We don't test this functionality (pulling a number out as a string). Almost commited a bug this would have caught.

Test Plan: Run the test.

Reviewed By: delong.j@fb.com

FB internal diff: D987607

folly/test/DynamicTest.cpp

index 163c6d35739df36021990206e97bba346ad32146..8cfe0b551fd9bf12c6059c9f16efd83cd783fe4e 100644 (file)
@@ -216,6 +216,10 @@ TEST(Dynamic, Conversions) {
   EXPECT_EQ(str.asInt(), 0);
   EXPECT_EQ(str.asDouble(), 0);
   EXPECT_EQ(str.asString(), "0");
+
+  dynamic num = 12;
+  EXPECT_EQ("12", num.asString());
+  EXPECT_EQ(12.0, num.asDouble());
 }
 
 TEST(Dynamic, FormattedIO) {