| 15 | #include <iostream> |
| 16 | |
| 17 | TEST(Memory, recover) { |
| 18 | cleanSlate(); // Clean up everything done so far |
| 19 | |
| 20 | try { |
| 21 | array vec[100]; |
| 22 | |
| 23 | // Trying to allocate 1 Terrabyte of memory and trash the memory manager |
| 24 | // should crash memory manager |
| 25 | for (int i = 0; i < 1000; i++) { |
| 26 | vec[i] = randu(1024, 1024, 256); // Allocating 1GB |
| 27 | } |
| 28 | |
| 29 | FAIL(); |
| 30 | } catch (exception &ae) { |
| 31 | ASSERT_EQ(ae.err(), AF_ERR_NO_MEM); |
| 32 | |
| 33 | const int num = 1000 * 1000; |
| 34 | const float val = 1.0; |
| 35 | |
| 36 | array a = constant(val, num); // This should work as expected |
| 37 | float *h_a = a.host<float>(); |
| 38 | for (int i = 0; i < 1000 * 1000; i++) { ASSERT_EQ(h_a[i], val); } |
| 39 | freeHost(h_a); |
| 40 | } |
| 41 | } |
nothing calls this directly
no test coverage detected