about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-09-15 00:38:00 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-09-15 00:38:00 -0700
commitdbf64731bc5313e2ceed16990680468ce977e3f2 (patch)
treedc0fec38d27b22b5e2bd57bd0662d1a41424630f
parent8bc3489f8f3ed5d0d8a19cadbba3cd81be7c4f1a (diff)
downloadmu-dbf64731bc5313e2ceed16990680468ce977e3f2.tar.gz
2201
-rw-r--r--010vm.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/010vm.cc b/010vm.cc
index 5e375409..ff6f7f30 100644
--- a/010vm.cc
+++ b/010vm.cc
@@ -311,6 +311,7 @@ ostream& operator<<(ostream& os, no_scientific x) {
 }
 
 string trim_floating_point(const string& in) {
+  if (in.empty()) return "";
   long long int len = SIZE(in);
   while (len > 1) {
     if (in.at(len-1) != '0') break;
@@ -322,8 +323,10 @@ string trim_floating_point(const string& in) {
 }
 
 void test_trim_floating_point() {
+  CHECK_EQ("", trim_floating_point(""));
   CHECK_EQ("0", trim_floating_point("000000000"));
-  CHECK_EQ("23.000001", trim_floating_point("23.000001"));
+  CHECK_EQ("1.5", trim_floating_point("1.5000"));
+  CHECK_EQ("1.000001", trim_floating_point("1.000001"));
   CHECK_EQ("23", trim_floating_point("23.000000"));
   CHECK_EQ("23", trim_floating_point("23.0"));
   CHECK_EQ("23", trim_floating_point("23."));
@@ -332,7 +335,6 @@ void test_trim_floating_point() {
   CHECK_EQ("3", trim_floating_point("3.0"));
   CHECK_EQ("3", trim_floating_point("3."));
   CHECK_EQ("3", trim_floating_point("3"));
-  CHECK_EQ("1.5", trim_floating_point("1.5000"));
 }
 
 :(before "End Includes")