-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[test] Adapt all timer and chrono tests
- Loading branch information
Showing
17 changed files
with
427 additions
and
414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (c) 2017-2018, Niklas Hauser | ||
* | ||
* This file is part of the modm project. | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
// ---------------------------------------------------------------------------- | ||
|
||
#include <modm/architecture/interface/clock.hpp> | ||
#include "clock.hpp" | ||
|
||
// ---------------------------------------------------------------------------- | ||
static uint32_t milli_time{0}; | ||
|
||
modm::chrono::milli_clock::time_point | ||
modm::chrono::milli_clock::now() noexcept | ||
{ | ||
return time_point{duration{milli_time}}; | ||
} | ||
|
||
void | ||
modm_test::chrono::milli_clock::setTime(uint32_t milliseconds) | ||
{ | ||
milli_time = milliseconds; | ||
} | ||
|
||
void | ||
modm_test::chrono::milli_clock::increment(uint32_t milliseconds) | ||
{ | ||
milli_time += milliseconds; | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
static uint32_t micro_time{0}; | ||
|
||
modm::chrono::micro_clock::time_point | ||
modm::chrono::micro_clock::now() noexcept | ||
{ | ||
return time_point{duration{micro_time}}; | ||
} | ||
|
||
void | ||
modm_test::chrono::micro_clock::setTime(uint32_t microseconds) | ||
{ | ||
micro_time = microseconds; | ||
} | ||
|
||
void | ||
modm_test::chrono::micro_clock::increment(uint32_t microseconds) | ||
{ | ||
micro_time += microseconds; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2020, Niklas Hauser | ||
* | ||
* This file is part of the modm project. | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
// ---------------------------------------------------------------------------- | ||
|
||
#pragma once | ||
#include <stdint.h> | ||
#include <modm/architecture/interface/clock.hpp> | ||
|
||
/// @ingroup modm_test_mock_clock | ||
namespace modm_test::chrono | ||
{ | ||
|
||
class milli_clock : modm::chrono::milli_clock | ||
{ | ||
public: | ||
static inline void setTime(std::chrono::milliseconds time) | ||
{ setTime(time.count()); } | ||
static void setTime(uint32_t milliseconds); | ||
|
||
static inline void increment(std::chrono::milliseconds time) | ||
{ increment(time.count()); } | ||
static void increment(uint32_t milliseconds); | ||
}; | ||
|
||
class micro_clock : modm::chrono::micro_clock | ||
{ | ||
public: | ||
static inline void setTime(std::chrono::microseconds time) | ||
{ setTime(time.count()); } | ||
static void setTime(uint32_t microseconds); | ||
|
||
static inline void increment(std::chrono::microseconds time) | ||
{ increment(time.count()); } | ||
static void increment(uint32_t microseconds); | ||
}; | ||
|
||
} // namespace modm_test |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.