From f461b3c1839e5cfc85685ed1cb828ecaa74d6912 Mon Sep 17 00:00:00 2001
From: Mike Buland <eichlan@xagasoft.com>
Date: Mon, 29 Dec 2008 21:33:08 +0000
Subject: Fixed some horror inside the Taf writer.  It had a strange corner
 case when adding a property to a group that had a name but an empty value.

Also added a isEmpty() function to Bu::FString, finally.
---
 src/unit/taf.cpp | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

(limited to 'src/unit')

diff --git a/src/unit/taf.cpp b/src/unit/taf.cpp
index 0813444..3bf7cc6 100644
--- a/src/unit/taf.cpp
+++ b/src/unit/taf.cpp
@@ -21,7 +21,8 @@ public:
 	{
 		setName("taf");
 		addTest( Unit::read1 );
-		addTest( Unit::encode );
+		addTest( Unit::encode1 );
+		addTest( Unit::emptyStr1 );
 	}
 
 	virtual ~Unit()
@@ -50,7 +51,7 @@ public:
 #undef FN_TMP
 	}
 
-	void encode()
+	void encode1()
 	{
 		Bu::MemBuf mb;
 		Bu::TafWriter tw( mb );
@@ -93,6 +94,20 @@ public:
 		unitTest( rg->getProperty("Encoded") == sData );
 		delete rg;
 	}
+
+	void emptyStr1()
+	{
+		Bu::MemBuf mb;
+		Bu::TafWriter tw( mb );
+
+		Bu::TafGroup g("Test Group");
+		Bu::FString sVal;
+		g.addChild( new Bu::TafProperty("Lame", sVal) );
+		tw.writeGroup( &g );
+
+		unitTest(
+			mb.getString() == "{\"Test Group\":\n    \"Lame\"=\"\"\n}\n" );
+	}
 };
 
 int main( int argc, char *argv[] )
-- 
cgit v1.2.3