Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit71c7f51

Browse files
Tests for stamp_dict
1 parent2f3fe32 commit71c7f51

File tree

4 files changed

+58
-3
lines changed

4 files changed

+58
-3
lines changed

‎blobstamper/stamp_dict.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
#include<limits.h>
66

7+
#include"blob.h"
8+
#include"stamp.h"
9+
#include"stamp_atomic.h"
710
#include"dict.h"
811

912
classStampDict:publicStampGeneric

‎t/120-stamp_dict.cpp‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#include<string.h>
2+
3+
#include<exception>
4+
#include<string>
5+
#include<cstdlib>
6+
#defineWANT_TEST_EXTRAS
7+
#include<tap++/tap++.h>
8+
9+
#include"blobstamper/dict.h"
10+
#include"blobstamper/stamp_dict.h"
11+
12+
classDictTest :publicDictBase
13+
{
14+
public:
15+
DictTest();
16+
};
17+
18+
DictTest::DictTest()
19+
{
20+
data = {"one","two","three","four"};
21+
}
22+
23+
usingnamespaceTAP;
24+
25+
/* Test that dict works as expected*/
26+
unsignedchar sample[]={0,63,64,255};
27+
28+
int
29+
main()
30+
{
31+
TEST_START(4);
32+
{/* 1..4*/
33+
DictTest dict;
34+
StampDictstamp(dict);
35+
Blobblob((char *) sample,4);
36+
std::string s;
37+
38+
s = blob.ShiftSingleStampStr(stamp);
39+
is(s,"one","0 stamps as first element of dict");
40+
41+
s = blob.ShiftSingleStampStr(stamp);
42+
is(s,"one","63 still stamps as first element of dict, when dict has only four elements");
43+
44+
s = blob.ShiftSingleStampStr(stamp);
45+
is(s,"two","64 stamps as second element of dict");
46+
47+
s = blob.ShiftSingleStampStr(stamp);
48+
is(s,"four","255 stamps as last (fourth) element of dict");
49+
50+
}
51+
TEST_END;
52+
}

‎t/200-dict.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ main()
3030

3131
{/* 1..2*/
3232
DictTest dict;
33-
ok(dict.size() ==3,"Dict size");
34-
ok(dict.get(1) =="two","Dict content");
33+
is(dict.size(),3,"Dict size");
34+
is(dict.get(1),"two","Dict content");
3535
}
3636

3737
TEST_END;

‎t/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ DEBUG := -ggdb3 -DDEBUG
66
CXXFLAGS :=$(DEBUG)$(WARNINGS) -fPIC
77
PREFIX := /usr/local
88
LIBRARY_VAR := LD_LIBRARY_PATH
9-
TEST_GOALS := ./00-sanity.t ./001-blob-generic.t ./100-stamp-base.t ./110-stamp-atomic.t ./200-dict.t ./300-galley.t ./500-stamp-pg-type-geo.t ./700-wrapper-pg-type-geo.t
9+
TEST_GOALS := ./00-sanity.t ./001-blob-generic.t ./100-stamp-base.t ./110-stamp-atomic.t ./120-stamp_dict.t ./200-dict.t ./300-galley.t ./500-stamp-pg-type-geo.t ./700-wrapper-pg-type-geo.t
1010

1111
all: build-libtappp$(TEST_GOALS)
1212

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp