Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 12674ea

Browse files
committed
C++: Add failing tests with 'CSimpleMap'.
1 parent 02b88d5 commit 12674ea

2 files changed

Lines changed: 97 additions & 0 deletions

File tree

cpp/ql/test/library-tests/dataflow/taint-tests/atl.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,3 +753,58 @@ void test_CSimpleArray() {
753753
sink(a2[pos]); // $ MISSING: ir
754754
}
755755
}
756+
757+
template <class TKey, class TVal>
758+
struct CSimpleMap {
759+
CSimpleMap();
760+
~CSimpleMap();
761+
762+
BOOL Add(const TKey& key, const TVal& val);
763+
int FindKey(const TKey& key) const;
764+
int FindVal(const TVal& val) const;
765+
TKey& GetKeyAt(int nIndex) const;
766+
int GetSize() const;
767+
TVal& GetValueAt(int nIndex) const;
768+
TVal Lookup(const TKey& key) const;
769+
BOOL Remove(const TKey& key);
770+
void RemoveAll();
771+
BOOL RemoveAt(int nIndex);
772+
TKey ReverseLookup(const TVal& val) const;
773+
BOOL SetAt(const TKey& key, const TVal& val);
774+
BOOL SetAtIndex(int nIndex, const TKey& key, const TVal& val);
775+
};
776+
777+
void test_CSimpleMap() {
778+
wchar_t* x = source<wchar_t*>();
779+
{
780+
CSimpleMap<char*, wchar_t*> a;
781+
a.Add("hello", x);
782+
sink(a.Lookup("hello")); // $ MISSING: ir
783+
}
784+
{
785+
CSimpleMap<char*, wchar_t*> a;
786+
auto pos = a.FindKey("hello");
787+
sink(a.GetValueAt(pos)); // $ MISSING: ir
788+
}
789+
{
790+
CSimpleMap<char*, wchar_t*> a;
791+
auto pos = a.FindVal(x);
792+
sink(a.GetValueAt(pos)); // $ MISSING: ir
793+
}
794+
{
795+
CSimpleMap<char*, wchar_t*> a;
796+
auto key = a.ReverseLookup(x);
797+
sink(key);
798+
sink(a.Lookup(key)); // $ MISSING: ir
799+
}
800+
{
801+
CSimpleMap<char*, wchar_t*> a;
802+
a.SetAt("hello", x);
803+
sink(a.Lookup("hello")); // $ MISSING: ir
804+
}
805+
{
806+
CSimpleMap<char*, wchar_t*> a;
807+
a.SetAtIndex(0, "hello", x);
808+
sink(a.Lookup("hello")); // $ MISSING: ir
809+
}
810+
}

cpp/ql/test/library-tests/dataflow/taint-tests/localTaint.expected

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,48 @@ WARNING: module 'TaintTracking' has been deprecated and may be removed in future
846846
| atl.cpp:751:23:751:24 | call to CSimpleArray | atl.cpp:754:3:754:3 | a2 | |
847847
| atl.cpp:752:18:752:21 | call to Find | atl.cpp:753:13:753:15 | pos | |
848848
| atl.cpp:753:10:753:11 | ref arg a2 | atl.cpp:754:3:754:3 | a2 | |
849+
| atl.cpp:778:16:778:31 | call to source | atl.cpp:781:20:781:20 | x | |
850+
| atl.cpp:778:16:778:31 | call to source | atl.cpp:791:26:791:26 | x | |
851+
| atl.cpp:778:16:778:31 | call to source | atl.cpp:796:32:796:32 | x | |
852+
| atl.cpp:778:16:778:31 | call to source | atl.cpp:802:22:802:22 | x | |
853+
| atl.cpp:778:16:778:31 | call to source | atl.cpp:807:30:807:30 | x | |
854+
| atl.cpp:780:33:780:33 | call to CSimpleMap | atl.cpp:781:5:781:5 | a | |
855+
| atl.cpp:780:33:780:33 | call to CSimpleMap | atl.cpp:782:10:782:10 | a | |
856+
| atl.cpp:780:33:780:33 | call to CSimpleMap | atl.cpp:783:3:783:3 | a | |
857+
| atl.cpp:781:5:781:5 | ref arg a | atl.cpp:782:10:782:10 | a | |
858+
| atl.cpp:781:5:781:5 | ref arg a | atl.cpp:783:3:783:3 | a | |
859+
| atl.cpp:782:10:782:10 | ref arg a | atl.cpp:783:3:783:3 | a | |
860+
| atl.cpp:785:33:785:33 | call to CSimpleMap | atl.cpp:786:16:786:16 | a | |
861+
| atl.cpp:785:33:785:33 | call to CSimpleMap | atl.cpp:787:10:787:10 | a | |
862+
| atl.cpp:785:33:785:33 | call to CSimpleMap | atl.cpp:788:3:788:3 | a | |
863+
| atl.cpp:786:18:786:24 | call to FindKey | atl.cpp:787:23:787:25 | pos | |
864+
| atl.cpp:787:10:787:10 | ref arg a | atl.cpp:788:3:788:3 | a | |
865+
| atl.cpp:790:33:790:33 | call to CSimpleMap | atl.cpp:791:16:791:16 | a | |
866+
| atl.cpp:790:33:790:33 | call to CSimpleMap | atl.cpp:792:10:792:10 | a | |
867+
| atl.cpp:790:33:790:33 | call to CSimpleMap | atl.cpp:793:3:793:3 | a | |
868+
| atl.cpp:791:18:791:24 | call to FindVal | atl.cpp:792:23:792:25 | pos | |
869+
| atl.cpp:792:10:792:10 | ref arg a | atl.cpp:793:3:793:3 | a | |
870+
| atl.cpp:795:33:795:33 | call to CSimpleMap | atl.cpp:796:16:796:16 | a | |
871+
| atl.cpp:795:33:795:33 | call to CSimpleMap | atl.cpp:798:10:798:10 | a | |
872+
| atl.cpp:795:33:795:33 | call to CSimpleMap | atl.cpp:799:3:799:3 | a | |
873+
| atl.cpp:796:16:796:16 | ref arg a | atl.cpp:798:10:798:10 | a | |
874+
| atl.cpp:796:16:796:16 | ref arg a | atl.cpp:799:3:799:3 | a | |
875+
| atl.cpp:796:18:796:30 | call to ReverseLookup | atl.cpp:797:10:797:12 | key | |
876+
| atl.cpp:796:18:796:30 | call to ReverseLookup | atl.cpp:798:19:798:21 | key | |
877+
| atl.cpp:797:10:797:12 | ref arg key | atl.cpp:798:19:798:21 | key | |
878+
| atl.cpp:798:10:798:10 | ref arg a | atl.cpp:799:3:799:3 | a | |
879+
| atl.cpp:801:33:801:33 | call to CSimpleMap | atl.cpp:802:5:802:5 | a | |
880+
| atl.cpp:801:33:801:33 | call to CSimpleMap | atl.cpp:803:10:803:10 | a | |
881+
| atl.cpp:801:33:801:33 | call to CSimpleMap | atl.cpp:804:3:804:3 | a | |
882+
| atl.cpp:802:5:802:5 | ref arg a | atl.cpp:803:10:803:10 | a | |
883+
| atl.cpp:802:5:802:5 | ref arg a | atl.cpp:804:3:804:3 | a | |
884+
| atl.cpp:803:10:803:10 | ref arg a | atl.cpp:804:3:804:3 | a | |
885+
| atl.cpp:806:33:806:33 | call to CSimpleMap | atl.cpp:807:5:807:5 | a | |
886+
| atl.cpp:806:33:806:33 | call to CSimpleMap | atl.cpp:808:10:808:10 | a | |
887+
| atl.cpp:806:33:806:33 | call to CSimpleMap | atl.cpp:809:3:809:3 | a | |
888+
| atl.cpp:807:5:807:5 | ref arg a | atl.cpp:808:10:808:10 | a | |
889+
| atl.cpp:807:5:807:5 | ref arg a | atl.cpp:809:3:809:3 | a | |
890+
| atl.cpp:808:10:808:10 | ref arg a | atl.cpp:809:3:809:3 | a | |
849891
| bsd.cpp:17:11:17:16 | call to source | bsd.cpp:20:18:20:18 | s | |
850892
| bsd.cpp:18:12:18:15 | addr | bsd.cpp:20:22:20:25 | addr | |
851893
| bsd.cpp:18:12:18:15 | addr | bsd.cpp:23:8:23:11 | addr | |

0 commit comments

Comments
 (0)