瀏覽代碼

[test] Add self-tests for strdup()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 10 年之前
父節點
當前提交
5249368950
共有 1 個檔案被更改,包括 10 行新增0 行删除
  1. 10
    0
      src/tests/string_test.c

+ 10
- 0
src/tests/string_test.c 查看文件

@@ -124,6 +124,16 @@ static void string_test_exec ( void ) {
124 124
 		memswap ( ( test + 1 ), ( test + 4 ), 3 );
125 125
 		ok ( memcmp ( test, expected, sizeof ( test ) ) == 0 );
126 126
 	}
127
+
128
+	/* Test strdup() */
129
+	{
130
+		const char *orig = "testing testing";
131
+		char *dup = strdup ( orig );
132
+		ok ( dup != NULL );
133
+		ok ( dup != orig );
134
+		ok ( strcmp ( dup, orig ) == 0 );
135
+		free ( dup );
136
+	}
127 137
 }
128 138
 
129 139
 /** String self-test */

Loading…
取消
儲存