Skip to content

Commit

Permalink
tests: added obj namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
KrystianD committed Feb 3, 2022
1 parent 449ff30 commit 9ddfe2c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions tests/obj.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#pragma once

namespace obj {
static int moves = 0;
static int copies = 0;

void clear() { moves = copies = 0; }

class Obj {
public:
int v;
Expand All @@ -21,11 +24,14 @@ class Obj {

Obj(Obj&& o) {
v = o.v;
o.v = 9999;
moves++;
}
Obj& operator=(Obj&& o) {
v = o.v;
o.v = 9999;
moves++;
return *this;
}
};
} // namespace obj
8 changes: 5 additions & 3 deletions tests/test_then.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ using namespace asyncpp_uv;

#include "obj.h"

using obj::Obj;

// void
task<void> test_void_ok() {
co_await uvSleepAsync(1000);
Expand Down Expand Up @@ -94,14 +96,14 @@ int main() {
printf("test_void_fail_late_failed: %d\n", test_void_fail_late_failed);
printf("test_obj_fail_early_failed: %d\n", test_obj_fail_early_failed);
printf("test_obj_fail_late_failed: %d\n", test_obj_fail_late_failed);
printf("copies: %d\n", copies);
printf("moves: %d\n", moves);
printf("copies: %d\n", obj::copies);
printf("moves: %d\n", obj::moves);

if (!test_void_fail_early_failed) return 1;
if (!test_void_fail_late_failed) return 1;
if (!test_obj_fail_early_failed) return 1;
if (!test_obj_fail_late_failed) return 1;
if (copies > 0) return 1;
if (obj::copies > 0) return 1;

return 0;
}

0 comments on commit 9ddfe2c

Please sign in to comment.