FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
quickfix-cpp/test/ComparatorTestCase.rb at master · brobits/quickfix-cpp · GitHub
brobits
quickfix-cpp
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
quickfix-cpp
/
test
/
ComparatorTestCase.rb
Copy path
More file actions
More file actions
Latest commit
History
History
History
37 lines (33 loc) · 1.47 KB
Breadcrumbs
quickfix-cpp
/
test
/
ComparatorTestCase.rb
Copy path
File metadata and controls
37 lines (33 loc) · 1.47 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require
'Comparator'
require
'runit/testcase'
class
ComparatorTestCase
<
RUNIT
::
TestCase
def
test_parsePatterns
patterns
=
"10=
\\
d{1,3}
\n
52=
\\
d{8}-
\\
d2:
\\
d2:
\\
d2
\n
"
comp
=
Comparator
.
new
(
patterns
)
assert_equals
(
/
\d
{1,3}/
,
comp
[
10
]
)
assert_equals
(
/
\d
{8}-
\d
2:
\d
2:
\d
2/
,
comp
[
52
]
)
end
def
test_compare
patterns
=
"10=
\\
d{1,3}
\n
52=
\\
d{8}-
\\
d{2}:
\\
d{2}:
\\
d{2}
\n
"
comp
=
Comparator
.
new
(
patterns
)
# matching fields
assert
(
comp
.
compare
(
"1=hello
\001
2=goodbye
\001
"
,
"1=hello
\001
2=goodbye
\001
"
)
)
assert
(
comp
.
reason
==
nil
)
# non-matching field
assert
(
!
comp
.
compare
(
"1=helloo
\001
2=goodbye
\001
"
,
"1=hello
\001
2=goodbye
\001
"
)
)
assert
(
comp
.
reason
==
"Value in field (1) should be (helloo) but was (hello)"
)
# out of order fields
assert
(
!
comp
.
compare
(
"2=hello
\001
1=goodbye
\001
"
,
"1=hello
\001
2=goodbye
\001
"
)
)
assert
(
comp
.
reason
==
"Expected field (2) but found field (1)"
)
# different number of fields
assert
(
!
comp
.
compare
(
"1=hello
\001
"
,
"1=hello
\001
2=goodbye
\001
"
)
)
assert
(
comp
.
reason
==
"Number of fields do not match"
)
# mathing non-deterministic field
assert
(
comp
.
compare
(
"1=hello
\001
2=goodbye
\001
52=12345678-12:23:34
\001
"
,
"1=hello
\001
2=goodbye
\001
52=87654321-98:87:76
\001
"
)
)
# non-matching non-deterministic field
assert
(
!
comp
.
compare
(
"1=hello
\001
2=goodbye
\001
52=12345678-12:23:34
\001
"
,
"1=hello
\001
2=goodbye
\001
52=7654321-98:87:76
\001
"
)
)
assert
(
comp
.
reason
==
"Field (52) does not match pattern"
)
end
end
Back
|
FazBrowse Home
|
New Git URL