FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
test_TaintString.c
1 /*********************************************************************
2 Copyright (C) 2012 Hewlett-Packard Development Company, L.P.
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 version 2 as published by the Free Software Foundation.
7 
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 
13 You should have received a copy of the GNU General Public License along
14 with this program; if not, write to the Free Software Foundation, Inc.,
15 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 *********************************************************************/
17 #include "run_tests.h"
21 static int Result = 0;
22 static int DestLen = 4096;
23 
29 void testTaintString1()
30 {
31  char Dest[DestLen];
32  char *Src = "test%sTaintstring";
33  Result = TaintString(Dest, DestLen, Src, 0, "Replace");
34  FO_ASSERT_EQUAL(Result, 0);
35  FO_ASSERT_STRING_EQUAL(Dest, "testReplaceTaintstring");
36 }
42 void testTaintString2()
43 {
44  char Dest[DestLen];
45  char *Src = "test\'Taintstring";
46  Result = TaintString(Dest, DestLen, Src, 1, NULL);
47  FO_ASSERT_EQUAL(Result, 0);
48  FO_ASSERT_STRING_EQUAL(Dest, "test'\\''Taintstring");
49 }
55 void testTaintString3()
56 {
57  char Dest[DestLen];
58  char *Src = "test\\Taintstring";
59  Result = TaintString(Dest, DestLen, Src, 0, NULL);
60  FO_ASSERT_EQUAL(Result, 0);
61  FO_ASSERT_STRING_EQUAL(Dest, "test\\\\Taintstring");
62 }
69 void testTaintString4()
70 {
71  char Dest[DestLen];
72  char *Src = "test\'Taintstring";
73  Result = TaintString(Dest, DestLen, Src, 0, NULL);
74  FO_ASSERT_EQUAL(Result, 0);
75  FO_ASSERT_STRING_EQUAL(Dest, "test'Taintstring");
76 }
77 
78 /* ************************************************************************** */
79 /* **** cunit test cases **************************************************** */
80 /* ************************************************************************** */
81 
82 CU_TestInfo TaintString_testcases[] =
83 {
84  {"TaintString1:", testTaintString1},
85  {"TaintString2:", testTaintString2},
86  {"TaintString3:", testTaintString3},
87  {"TaintString4:", testTaintString4},
88  CU_TEST_INFO_NULL
89 };
static int Result
Result of calls.
Definition: test_CopyFile.c:28
CU_TestInfo TaintString_testcases[]
TaintString() test cases.
static char * Src
Souce location.
Definition: test_CopyFile.c:24
char * TaintString(char *S)
Create a string with taint quoting.
Definition: finder.c:46