mirror of https://github.com/ARMmbed/mbed-os.git
Added MBED_26 Integer constant division test to test suite
parent
38f84aa194
commit
5804ee610b
|
|
@ -1,4 +1,6 @@
|
||||||
|
#include <utility> // std::pair
|
||||||
#include "mbed.h"
|
#include "mbed.h"
|
||||||
|
#include "test_env.h"
|
||||||
|
|
||||||
uint32_t test_64(uint64_t ticks) {
|
uint32_t test_64(uint64_t ticks) {
|
||||||
ticks >>= 3; // divide by 8
|
ticks >>= 3; // divide by 8
|
||||||
|
|
@ -10,18 +12,30 @@ uint32_t test_64(uint64_t ticks) {
|
||||||
return (uint32_t)(0xFFFFFFFF & ticks);
|
return (uint32_t)(0xFFFFFFFF & ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
const char *result_str(bool result) {
|
||||||
// 0xFFFFFFFF * 8 = 0x7fffffff8
|
return result ? "[OK]" : "[FAIL]";
|
||||||
printf("expected : 55555555\n");
|
}
|
||||||
printf("64: 0x7fffffff8: %x\n", test_64(0x7fffffff8));
|
|
||||||
|
int main() {
|
||||||
// 0xFFFFFFFF * 24 = 0x17ffffffe8
|
DigitalOut led(LED1);
|
||||||
printf("expected : ffffffff\n");
|
bool result = true;
|
||||||
printf("64: 0x17ffffffe8: %x\n", test_64(0x17FFFFFFE8));
|
|
||||||
|
{ // 0xFFFFFFFF * 8 = 0x7fffffff8
|
||||||
DigitalOut led(LED1);
|
std::pair<uint32_t, uint64_t> values = std::make_pair(0x55555555, 0x7FFFFFFF8);
|
||||||
while (1) {
|
uint32_t test_ret = test_64(values.second);
|
||||||
led = !led;
|
bool test_res = values.first == test_ret;
|
||||||
wait(0.5);
|
result = result && test_res;
|
||||||
}
|
printf("64bit: 0x7FFFFFFF8: expected 0x%X got 0x%X ... %s\r\n", values.first, test_ret, result_str(test_res));
|
||||||
|
}
|
||||||
|
|
||||||
|
{ // 0xFFFFFFFF * 24 = 0x17ffffffe8
|
||||||
|
std::pair<uint32_t, uint64_t> values = std::make_pair(0xFFFFFFFF, 0x17FFFFFFE8);
|
||||||
|
uint32_t test_ret = test_64(values.second);
|
||||||
|
bool test_res = values.first == test_ret;
|
||||||
|
result = result && test_res;
|
||||||
|
printf("64bit: 0x17FFFFFFE8: expected 0x%X got 0x%X ... %s\r\n", values.first, test_ret, result_str(test_res));
|
||||||
|
}
|
||||||
|
|
||||||
|
notify_completion(result);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -423,6 +423,7 @@ TESTS = [
|
||||||
"id": "MBED_26", "description": "Integer constant division",
|
"id": "MBED_26", "description": "Integer constant division",
|
||||||
"source_dir": join(TEST_DIR, "mbed", "div"),
|
"source_dir": join(TEST_DIR, "mbed", "div"),
|
||||||
"dependencies": [MBED_LIBRARIES, TEST_MBED_LIB],
|
"dependencies": [MBED_LIBRARIES, TEST_MBED_LIB],
|
||||||
|
"automated": True,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "MBED_27", "description": "SPI ADXL345",
|
"id": "MBED_27", "description": "SPI ADXL345",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue