+ buf = ensure_nlterm( NULL );
+ errors += fail_if_nil( buf, "ensure nlterm returned null pointer when given nil ptr" );
+ if( buf ) {
+ errors += fail_not_equal( strlen( buf ), 1, "ensure nlterm returned incorrect length string when given nil pointer" );
+ free( buf );
+ }
+
+ buf = ensure_nlterm( strdup( "x" ) ); // should return "x\n"
+ errors += fail_if_nil( buf, "ensure nlterm returned null pointer when given single char string" );
+ if( buf ) {
+ errors += fail_not_equal( strlen( buf ), 2, "ensure nlterm returned incorrect length string when given single char string" );
+ free( buf );
+ }
+
+ buf = strdup( "x\n" );
+ buf2 = ensure_nlterm( buf ); // buffer returned should be the same
+ if( fail_not_pequal( buf, buf2, "ensure nlterm returned new buffer for one char string with newline" ) ) {
+ errors++;
+ free( buf2 );
+ }
+ free( buf );
+
+ buf = strdup( "Missing our trips to Gloria's for papossas.\n" );
+ buf2 = ensure_nlterm( buf ); // buffer returned should be the same
+ if( fail_not_pequal( buf, buf2, "ensure nlterm returned new buffer for string with newline" ) ) {
+ errors++;
+ free( buf2 );
+ }
+ free( buf );
+