FOSSology  4.4.0
Open Source License Compliance by Open Source Software
test_TaintString.c
1 /*
2  SPDX-FileCopyrightText: © 2012 Hewlett-Packard Development Company, L.P.
3 
4  SPDX-License-Identifier: GPL-2.0-only
5 */
6 #include "run_tests.h"
10 static int Result = 0;
11 static int DestLen = 4096;
12 
18 void testTaintString1()
19 {
20  char Dest[DestLen];
21  char *Src = "test%sTaintstring";
22  Result = TaintString(Dest, DestLen, Src, 0, "Replace");
23  FO_ASSERT_EQUAL(Result, 0);
24  FO_ASSERT_STRING_EQUAL(Dest, "testReplaceTaintstring");
25 }
31 void testTaintString2()
32 {
33  char Dest[DestLen];
34  char *Src = "test\'Taintstring";
35  Result = TaintString(Dest, DestLen, Src, 1, NULL);
36  FO_ASSERT_EQUAL(Result, 0);
37  FO_ASSERT_STRING_EQUAL(Dest, "test'\\''Taintstring");
38 }
44 void testTaintString3()
45 {
46  char Dest[DestLen];
47  char *Src = "test\\Taintstring";
48  Result = TaintString(Dest, DestLen, Src, 0, NULL);
49  FO_ASSERT_EQUAL(Result, 0);
50  FO_ASSERT_STRING_EQUAL(Dest, "test\\\\Taintstring");
51 }
58 void testTaintString4()
59 {
60  char Dest[DestLen];
61  char *Src = "test\'Taintstring";
62  Result = TaintString(Dest, DestLen, Src, 0, NULL);
63  FO_ASSERT_EQUAL(Result, 0);
64  FO_ASSERT_STRING_EQUAL(Dest, "test'Taintstring");
65 }
66 
67 /* ************************************************************************** */
68 /* **** cunit test cases **************************************************** */
69 /* ************************************************************************** */
70 
71 CU_TestInfo TaintString_testcases[] =
72 {
73  {"TaintString1:", testTaintString1},
74  {"TaintString2:", testTaintString2},
75  {"TaintString3:", testTaintString3},
76  {"TaintString4:", testTaintString4},
77  CU_TEST_INFO_NULL
78 };
char * TaintString(char *S)
Create a string with taint quoting.
Definition: finder.c:35
static int Result
Result of calls.
Definition: test_CopyFile.c:17
static char * Src
Souce location.
Definition: test_CopyFile.c:13
CU_TestInfo TaintString_testcases[]
TaintString() test cases.