Alexei Frolov | c10c812 | 2019-11-01 16:31:19 -0700 | [diff] [blame] | 1 | // Copyright 2019 The Pigweed Authors |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not |
Wyatt Hepler | 1a96094 | 2019-11-26 14:13:38 -0800 | [diff] [blame] | 4 | // use this file except in compliance with the License. You may obtain a copy of |
| 5 | // the License at |
Alexei Frolov | c10c812 | 2019-11-01 16:31:19 -0700 | [diff] [blame] | 6 | // |
| 7 | // https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
Wyatt Hepler | 1a96094 | 2019-11-26 14:13:38 -0800 | [diff] [blame] | 12 | // License for the specific language governing permissions and limitations under |
| 13 | // the License. |
Alexei Frolov | c10c812 | 2019-11-01 16:31:19 -0700 | [diff] [blame] | 14 | |
Armando Montanez | d3ed0f4 | 2019-11-18 11:15:42 -0800 | [diff] [blame] | 15 | #include <string_view> |
Alexei Frolov | c10c812 | 2019-11-01 16:31:19 -0700 | [diff] [blame] | 16 | |
Wyatt Hepler | 8663e9c | 2019-11-20 13:58:29 -0800 | [diff] [blame] | 17 | #include "pw_span/span.h" |
Armando Montanez | f7a5a74 | 2020-03-02 14:58:59 -0800 | [diff] [blame] | 18 | #include "pw_sys_io/sys_io.h" |
Alexei Frolov | c10c812 | 2019-11-01 16:31:19 -0700 | [diff] [blame] | 19 | #include "pw_unit_test/framework.h" |
| 20 | #include "pw_unit_test/simple_printing_event_handler.h" |
| 21 | |
Alexei Frolov | c10c812 | 2019-11-01 16:31:19 -0700 | [diff] [blame] | 22 | int main() { |
| 23 | pw::unit_test::SimplePrintingEventHandler handler( |
Wyatt Hepler | 8663e9c | 2019-11-20 13:58:29 -0800 | [diff] [blame] | 24 | [](const std::string_view& s, bool append_newline) { |
| 25 | if (append_newline) { |
Armando Montanez | f7a5a74 | 2020-03-02 14:58:59 -0800 | [diff] [blame] | 26 | pw::sys_io::WriteLine(s); |
Wyatt Hepler | 8663e9c | 2019-11-20 13:58:29 -0800 | [diff] [blame] | 27 | } else { |
Armando Montanez | f7a5a74 | 2020-03-02 14:58:59 -0800 | [diff] [blame] | 28 | pw::sys_io::WriteBytes(pw::as_bytes(pw::span(s))); |
Wyatt Hepler | 8663e9c | 2019-11-20 13:58:29 -0800 | [diff] [blame] | 29 | } |
Armando Montanez | d3ed0f4 | 2019-11-18 11:15:42 -0800 | [diff] [blame] | 30 | }); |
Wyatt Hepler | 8663e9c | 2019-11-20 13:58:29 -0800 | [diff] [blame] | 31 | |
Alexei Frolov | c10c812 | 2019-11-01 16:31:19 -0700 | [diff] [blame] | 32 | pw::unit_test::RegisterEventHandler(&handler); |
| 33 | return RUN_ALL_TESTS(); |
| 34 | } |