MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / TEST

Function TEST

test/manual_memory_test.cpp:17–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15#include <iostream>
16
17TEST(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}

Callers

nothing calls this directly

Calls 4

cleanSlateFunction · 0.85
randuFunction · 0.85
constantFunction · 0.85
freeHostFunction · 0.85

Tested by

no test coverage detected