-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
passed unit-test for buff and callback
- Loading branch information
Showing
15 changed files
with
187 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,66 @@ | ||
#include <string> | ||
#include <iostream> | ||
using namespace std; | ||
// Copyright (c) 2014 The SealedServer Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. See the AUTHORS file for names of contributors. | ||
|
||
#include "Buffer.h" | ||
#include "Tester.h" | ||
using namespace utils; | ||
|
||
void TestBuffer(const Buffer buf) | ||
class A | ||
{ | ||
Buffer buf; | ||
public: | ||
A() : buf("hello world") { } | ||
|
||
int size() { return buf.size(); } | ||
}; | ||
|
||
/** | ||
** Test for size | ||
**/ | ||
TEST(A, Size) | ||
{ | ||
cout<<"len2:"<<buf.length()<<endl; | ||
} | ||
ASSERT_EQ(size(), 11); | ||
}; | ||
|
||
/** | ||
** Test for counter | ||
** Expect behavior: release/output/release/release | ||
**/ | ||
TEST(A, Counter) | ||
{ | ||
Buffer buff; | ||
|
||
{ | ||
Buffer buff1("hello world"); | ||
buff = buff1; | ||
} | ||
|
||
cout << (string)buff << endl; | ||
}; | ||
|
||
/** | ||
** Test for counter | ||
** Expect behavior: release/output/release/release | ||
**/ | ||
TEST(A, SelfAlloc) | ||
{ | ||
Buffer buff; | ||
|
||
{ | ||
char * str = new char[10]; | ||
memset(str, 0, 10); | ||
strncpy(str, "great day", 9); | ||
|
||
Buffer buff1(str, true); | ||
buff = buff1; | ||
} | ||
|
||
cout << (string)buff << endl; | ||
}; | ||
|
||
int main() | ||
{ | ||
Buffer buf("hello world"); | ||
cout<<"len1:"<<buf.length()<<endl; | ||
TestBuffer(buf); | ||
RunAllTests(); | ||
return 0; | ||
} |
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 |
---|---|---|
@@ -1,21 +1,63 @@ | ||
#include <stdio.h> | ||
// Copyright (c) 2014 The SealedServer Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. See the AUTHORS file for names of contributors. | ||
|
||
#include "Tester.h" | ||
#include "Callback.h" | ||
using namespace utils; | ||
|
||
class A | ||
class A | ||
{ | ||
|
||
}; | ||
|
||
class B | ||
{ | ||
public: | ||
void a() | ||
void b() | ||
{ | ||
printf("hello, enter function a\n"); | ||
printf("hello, enter function b\n"); | ||
} | ||
|
||
~B() | ||
{ | ||
printf("release B\n"); | ||
} | ||
}; | ||
|
||
int main() | ||
TEST(A, callfromb) | ||
{ | ||
B b1; | ||
Callback<void> call(&b1, &B::b); | ||
call(); | ||
} | ||
|
||
TEST(A, equal) | ||
{ | ||
A a1; | ||
Callback<void> call(a1, &A::a); | ||
Callback<void> call; | ||
|
||
B b1; | ||
call = Callback<void>(&b1, &B::b); | ||
call(); | ||
} | ||
|
||
/** | ||
** Should throw exception, bug | ||
**/ | ||
TEST(A, null) | ||
{ | ||
Callback<void> call; | ||
|
||
{ | ||
B b1; | ||
call = Callback<void>(&b1, &B::b); | ||
} | ||
|
||
call(); | ||
} | ||
|
||
int main() | ||
{ | ||
RunAllTests(); | ||
return 0; | ||
} |
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 |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
#ifndef _C_H | ||
#define _C_H | ||
|
||
#include "Header.h" | ||
|
||
/** | ||
** C.h provides some C-like helper functions | ||
** | ||
|
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.