-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #138 from robotpy/more-tests
More tests
- Loading branch information
Showing
9 changed files
with
123 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
|
||
enums: | ||
StripPrefixEnum: | ||
value_prefix: STRIP_ |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
#include <stdint.h> | ||
|
||
class ClassWithFields { | ||
public: | ||
ClassWithFields() : ref_int(actual_int) { | ||
array_of_two[0] = 0x10; | ||
array_of_two[1] = 0x22; | ||
|
||
ref_int = actual_int; | ||
} | ||
|
||
// array with size | ||
int array_of_two[2]; | ||
|
||
int get_array_of_two(int index) { return array_of_two[index]; } | ||
|
||
// readwrite | ||
int actual_int = 2; | ||
|
||
// reference | ||
int &ref_int; | ||
|
||
// constant | ||
const int const_field = 3; | ||
|
||
// static | ||
static int static_int; | ||
|
||
// constant static | ||
const static int static_const = 5; | ||
|
||
// constexpr | ||
constexpr static int static_constexpr = 6; | ||
|
||
// there's no sensible way to deal with this automatically | ||
int should_be_ignored[]; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
#include <fields.h> | ||
|
||
int ClassWithFields::static_int = 4; | ||
const int ClassWithFields::static_const; |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from rpytest.ft import ClassWithFields | ||
|
||
|
||
def test_fields(): | ||
|
||
c = ClassWithFields() | ||
|
||
assert "should_be_ignored" not in dir(c) | ||
assert "array_of_two" in dir(c) | ||
|
||
assert len(c.array_of_two) == 2 | ||
assert c.array_of_two[0] == 0x10 | ||
assert c.array_of_two[1] == 0x22 | ||
|
||
c.array_of_two[1] = 0x42 | ||
assert c.get_array_of_two(1) == 0x42 | ||
|
||
assert c.const_field == 3 | ||
|
||
assert ClassWithFields.static_int == 4 | ||
ClassWithFields.static_int = 44 | ||
assert ClassWithFields.static_int == 44 | ||
|
||
assert ClassWithFields.static_const == 5 | ||
assert ClassWithFields.static_constexpr == 6 | ||
|
||
assert c.actual_int == 2 | ||
assert c.ref_int == 2 | ||
|
||
c.actual_int = 3 | ||
assert c.ref_int == 3 | ||
|
||
# TODO: this probably has subtle issues, should always | ||
# be readonly? | ||
c.ref_int = 4 | ||
assert c.actual_int == 4 |