Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cdo
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpim-sw
cdo
Commits
b491385d
Commit
b491385d
authored
2 months ago
by
Oliver Heidmann
Committed by
Uwe Schulzweida
2 months ago
Browse files
Options
Downloads
Patches
Plain Diff
removed old tests for old function, added new rudimentary tests for string_to_number
parent
584ea9d5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!326
convert_to_number not called string_to_number, fixed usage of .fail enabling...
,
!322
Fixing and cleaning up handling of operator argument sourrounding the use of scientific notations
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/bandit_tests/util_string.cc
+30
-51
30 additions, 51 deletions
test/bandit_tests/util_string.cc
with
30 additions
and
51 deletions
test/bandit_tests/util_string.cc
+
30
−
51
View file @
b491385d
...
@@ -13,57 +13,6 @@ cdoExit()
...
@@ -13,57 +13,6 @@ cdoExit()
}
}
go_bandit
([]()
{
go_bandit
([]()
{
//==============================================================================
//==============================================================================
bandit
::
describe
(
"Testing function 'tokenize_comma_seperated_int_list'"
,
[]()
{
bandit
::
describe
(
"Testing tokenization with proper input"
,
[]()
{
std
::
string
to_be_tokenized
{
"1,-2.0,1.0e3,-4.5e-2,0,0.0e043"
};
std
::
vector
<
float
>
expected_tokens
=
{
1
,
-
2.0
,
1000.0
,
-
0.045
,
0
,
0.0
};
std
::
pair
<
bool
,
std
::
vector
<
float
>>
result
=
tokenize_comma_seperated_number_list
<
float
>
(
to_be_tokenized
);
bandit
::
it
(
"returns true on success"
,
[
&
]()
{
AssertThat
(
std
::
get
<
0
>
(
result
),
Equals
(
true
));
});
bandit
::
it
(
"returns the right tokens"
,
[
&
]()
{
AssertThat
(
std
::
get
<
1
>
(
result
),
EqualsContainer
(
expected_tokens
));
});
});
bandit
::
describe
(
"Testing tokenization with proper input"
,
[]()
{
std
::
string
to_be_tokenized
{
"1,-2.0,1.0e3,-4.5e-2"
};
std
::
vector
<
double
>
expected_tokens
=
{
1
,
-
2.0
,
1000.0
,
-
0.045
};
std
::
pair
<
bool
,
std
::
vector
<
double
>>
result
=
tokenize_comma_seperated_number_list
<
double
>
(
to_be_tokenized
);
bandit
::
it
(
"returns true on success"
,
[
&
]()
{
AssertThat
(
std
::
get
<
0
>
(
result
),
Equals
(
true
));
});
bandit
::
it
(
"returns the right tokens"
,
[
&
]()
{
AssertThat
(
std
::
get
<
1
>
(
result
),
EqualsContainer
(
expected_tokens
));
});
});
});
bandit
::
describe
(
"Testing function 'tokenize_comma_seperated_int_list'"
,
[]()
{
bandit
::
describe
(
"Testing tokenization with proper input"
,
[]()
{
std
::
string
to_be_tokenized
{
"1,-2,3,4"
};
std
::
vector
<
std
::
string
>
expected_tokens
=
{
"1"
,
"-2"
,
"3"
,
"4"
};
std
::
tuple
<
bool
,
std
::
vector
<
std
::
string
>>
result
=
tokenize_comma_seperated_int_list
(
to_be_tokenized
);
bandit
::
it
(
"returns true on success"
,
[
&
]()
{
AssertThat
(
std
::
get
<
0
>
(
result
),
Equals
(
true
));
});
bandit
::
it
(
"returns the right tokens"
,
[
&
]()
{
AssertThat
(
std
::
get
<
1
>
(
result
),
EqualsContainer
(
expected_tokens
));
});
});
bandit
::
describe
(
"Testing tokenization with input containing non int"
,
[]()
{
std
::
vector
<
std
::
string
>
expected_tokens
=
{};
std
::
string
to_be_tokenized
{
"1,a,3,4"
};
std
::
tuple
<
bool
,
std
::
vector
<
std
::
string
>>
result
=
tokenize_comma_seperated_int_list
(
to_be_tokenized
);
bandit
::
it
(
"returns false on failure"
,
[
&
]()
{
AssertThat
(
std
::
get
<
0
>
(
result
),
Equals
(
false
));
});
bandit
::
it
(
"returns a empty list"
,
[
&
]()
{
AssertThat
(
std
::
get
<
1
>
(
result
),
EqualsContainer
(
expected_tokens
));
});
});
bandit
::
describe
(
"Testing tokenization with input containing a float value"
,
[]()
{
std
::
vector
<
std
::
string
>
expected_tokens
=
{};
std
::
string
to_be_tokenized
{
"1,1.2,3"
};
std
::
tuple
<
bool
,
std
::
vector
<
std
::
string
>>
result
=
tokenize_comma_seperated_int_list
(
to_be_tokenized
);
bandit
::
it
(
"returns false"
,
[
&
]()
{
AssertThat
(
std
::
get
<
0
>
(
result
),
Equals
(
false
));
});
bandit
::
it
(
"returns empty list"
,
[
&
]()
{
AssertThat
(
std
::
get
<
1
>
(
result
),
EqualsContainer
(
expected_tokens
));
});
});
bandit
::
describe
(
"Testing tokenization with input containing a single value"
,
[]()
{
std
::
vector
<
std
::
string
>
expected_tokens
=
{
"1"
};
std
::
string
to_be_tokenized
{
"1"
};
std
::
tuple
<
bool
,
std
::
vector
<
std
::
string
>>
result
=
tokenize_comma_seperated_int_list
(
to_be_tokenized
);
bandit
::
it
(
"returns true"
,
[
&
]()
{
AssertThat
(
std
::
get
<
0
>
(
result
),
Equals
(
true
));
});
bandit
::
it
(
"returns the token '1'"
,
[
&
]()
{
AssertThat
(
std
::
get
<
1
>
(
result
),
EqualsContainer
(
expected_tokens
));
});
});
});
bandit
::
describe
(
"Testing trim functions"
,
[]()
{
bandit
::
describe
(
"Testing trim functions"
,
[]()
{
bandit
::
describe
(
"Testing ltrim function"
,
[]()
{
bandit
::
describe
(
"Testing ltrim function"
,
[]()
{
std
::
string
to_be_trimmed
=
" spaces in front "
;
std
::
string
to_be_trimmed
=
" spaces in front "
;
...
@@ -74,6 +23,36 @@ go_bandit([]() {
...
@@ -74,6 +23,36 @@ go_bandit([]() {
});
});
});
});
});
});
bandit
::
describe
(
"Testing string_to_number"
,
[]()
{
bandit
::
describe
(
"Testing float"
,
[]()
{
std
::
string
test_str
=
"0.02"
;
float
expected
=
0.02
;
bandit
::
it
(
"correctly converts"
,
[
&
]()
{
auto
[
success
,
result
]
=
string_to_number
<
float
>
(
test_str
);
AssertThat
(
success
,
Equals
(
true
));
AssertThat
(
result
,
Equals
(
expected
));
});
});
bandit
::
describe
(
"Testing int"
,
[]()
{
std
::
string
test_str
=
"2"
;
int
expected
=
2
;
bandit
::
it
(
"correctly converts"
,
[
&
]()
{
auto
[
success
,
result
]
=
string_to_number
<
int
>
(
test_str
);
AssertThat
(
success
,
Equals
(
true
));
AssertThat
(
result
,
Equals
(
expected
));
});
});
bandit
::
describe
(
"Testing double"
,
[]()
{
std
::
string
test_str
=
"0.02"
;
double
expected
=
0.02
;
bandit
::
it
(
"correctly converts"
,
[
&
]()
{
auto
[
success
,
result
]
=
string_to_number
<
double
>
(
test_str
);
AssertThat
(
success
,
Equals
(
true
));
AssertThat
(
result
,
Equals
(
expected
));
});
});
});
bandit
::
describe
(
"Testing rtrim function"
,
[]()
{
bandit
::
describe
(
"Testing rtrim function"
,
[]()
{
std
::
string
to_be_trimmed
=
" spaces in back "
;
std
::
string
to_be_trimmed
=
" spaces in back "
;
std
::
string
expected
=
" spaces in back"
;
std
::
string
expected
=
" spaces in back"
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment