Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
33e15c8b
Commit
33e15c8b
authored
May 22, 2019
by
Paul
Browse files
Formatting
parent
7c9c11d7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
25 deletions
+23
-25
src/include/migraphx/stringutils.hpp
src/include/migraphx/stringutils.hpp
+7
-7
test/eval_test.cpp
test/eval_test.cpp
+16
-18
No files found.
src/include/migraphx/stringutils.hpp
View file @
33e15c8b
...
...
@@ -43,17 +43,17 @@ inline std::string join_strings(Strings strings, const std::string& delim)
});
}
template
<
class
F
>
std
::
string
trim
(
const
std
::
string
&
s
,
F
f
)
template
<
class
F
>
std
::
string
trim
(
const
std
::
string
&
s
,
F
f
)
{
auto
start
=
std
::
find_if_not
(
s
.
begin
(),
s
.
end
(),
f
);
auto
last
=
std
::
find_if_not
(
s
.
rbegin
(),
std
::
string
::
const_reverse_iterator
(
start
),
f
).
base
();
return
std
::
string
(
start
,
last
);
auto
start
=
std
::
find_if_not
(
s
.
begin
(),
s
.
end
(),
f
);
auto
last
=
std
::
find_if_not
(
s
.
rbegin
(),
std
::
string
::
const_reverse_iterator
(
start
),
f
).
base
();
return
std
::
string
(
start
,
last
);
}
inline
std
::
string
trim
(
const
std
::
string
&
s
)
inline
std
::
string
trim
(
const
std
::
string
&
s
)
{
return
trim
(
s
,
[](
int
c
){
return
std
::
isspace
(
c
);
});
return
trim
(
s
,
[](
int
c
)
{
return
std
::
isspace
(
c
);
});
}
template
<
class
F
>
...
...
test/eval_test.cpp
View file @
33e15c8b
...
...
@@ -403,7 +403,7 @@ TEST_CASE(reverse_target_test)
auto
one
=
p
.
add_literal
(
1
);
auto
two
=
p
.
add_literal
(
2
);
p
.
add_instruction
(
sum_op
{},
one
,
two
);
EXPECT
(
test
::
throws
<
migraphx
::
exception
>
([
&
]{
p
.
compile
(
reverse_target
{});
}));
EXPECT
(
test
::
throws
<
migraphx
::
exception
>
([
&
]
{
p
.
compile
(
reverse_target
{});
}));
}
// Check that the program doesnt modify the context directly, and only the operators modify the
...
...
@@ -454,23 +454,21 @@ TEST_CASE(eval_context3)
EXPECT
(
not
is_shared
(
t
.
ctx
,
p
.
get_context
()));
}
struct
cout_redirect
{
cout_redirect
()
=
delete
;
cout_redirect
(
const
cout_redirect
&
)
=
delete
;
template
<
class
T
>
cout_redirect
(
T
&
stream
)
:
old
(
std
::
cout
.
rdbuf
(
stream
.
rdbuf
()))
{}
~
cout_redirect
()
struct
cout_redirect
{
cout_redirect
()
=
delete
;
cout_redirect
(
const
cout_redirect
&
)
=
delete
;
template
<
class
T
>
cout_redirect
(
T
&
stream
)
:
old
(
std
::
cout
.
rdbuf
(
stream
.
rdbuf
()))
{
std
::
cout
.
rdbuf
(
old
);
}
~
cout_redirect
()
{
std
::
cout
.
rdbuf
(
old
);
}
private:
std
::
streambuf
*
old
;
private:
std
::
streambuf
*
old
;
};
template
<
class
F
>
template
<
class
F
>
std
::
string
capture_output
(
F
f
)
{
std
::
stringstream
ss
;
...
...
@@ -487,11 +485,11 @@ TEST_CASE(debug_print_test)
migraphx
::
program
p2
;
auto
one2
=
p2
.
add_literal
(
1
);
auto
program_out
=
migraphx
::
trim
(
capture_output
([
&
]{
p
.
debug_print
();
}));
auto
ins_out
=
migraphx
::
trim
(
capture_output
([
&
]{
p
.
debug_print
(
one
);
}));
auto
inss_out
=
migraphx
::
trim
(
capture_output
([
&
]{
p
.
debug_print
({
one
});
}));
auto
end_out
=
migraphx
::
trim
(
capture_output
([
&
]{
p
.
debug_print
(
p
.
end
());
}));
auto
p2_ins_out
=
migraphx
::
trim
(
capture_output
([
&
]{
p
.
debug_print
(
one2
);
}));
auto
program_out
=
migraphx
::
trim
(
capture_output
([
&
]
{
p
.
debug_print
();
}));
auto
ins_out
=
migraphx
::
trim
(
capture_output
([
&
]
{
p
.
debug_print
(
one
);
}));
auto
inss_out
=
migraphx
::
trim
(
capture_output
([
&
]
{
p
.
debug_print
({
one
});
}));
auto
end_out
=
migraphx
::
trim
(
capture_output
([
&
]
{
p
.
debug_print
(
p
.
end
());
}));
auto
p2_ins_out
=
migraphx
::
trim
(
capture_output
([
&
]
{
p
.
debug_print
(
one2
);
}));
EXPECT
(
program_out
==
ins_out
);
EXPECT
(
inss_out
==
ins_out
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment