-
Notifications
You must be signed in to change notification settings - Fork 4
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 #11 from marc-christian-schulze/constants
Constants
- Loading branch information
Showing
16 changed files
with
571 additions
and
71 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
51 changes: 51 additions & 0 deletions
51
...a.parent/org.structs4java.tests/src/org/structs4java/tests/DefaultValuesParsingTest.xtend
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,51 @@ | ||
package org.structs4java.tests | ||
|
||
import com.google.inject.Inject | ||
import org.eclipse.xtext.testing.InjectWith | ||
import org.eclipse.xtext.testing.XtextRunner | ||
import org.eclipse.xtext.testing.util.ParseHelper | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.structs4java.structs4JavaDsl.IntegerMember | ||
import org.structs4java.structs4JavaDsl.FloatMember | ||
|
||
import static org.junit.Assert.assertEquals | ||
|
||
@RunWith(XtextRunner) | ||
@InjectWith(Structs4JavaDslInjectorProvider) | ||
class DefaultValuesParsingTest { | ||
|
||
@Inject | ||
ParseHelper<org.structs4java.structs4JavaDsl.StructsFile> parseHelper | ||
|
||
@Test | ||
def void structWithValidPrimitivesWithDefaultValues() { | ||
val pkg = parseHelper.parse(''' | ||
struct S { | ||
int8_t a = 1; | ||
uint8_t b = 2; | ||
int16_t c = 3; | ||
uint16_t d = 4; | ||
int32_t e = 5; | ||
uint32_t f = 6; | ||
int64_t g = 7; | ||
uint64_t h = 8; | ||
float i = 1.0; | ||
double j = 2.0; | ||
} | ||
''') | ||
val struct = pkg.structs.get(0) | ||
|
||
assertEquals(1L, (struct.members.get(0) as IntegerMember).defaultValue) | ||
assertEquals(2L, (struct.members.get(1) as IntegerMember).defaultValue) | ||
assertEquals(3L, (struct.members.get(2) as IntegerMember).defaultValue) | ||
assertEquals(4L, (struct.members.get(3) as IntegerMember).defaultValue) | ||
assertEquals(5L, (struct.members.get(4) as IntegerMember).defaultValue) | ||
assertEquals(6L, (struct.members.get(5) as IntegerMember).defaultValue) | ||
assertEquals(7L, (struct.members.get(6) as IntegerMember).defaultValue) | ||
assertEquals(8L, (struct.members.get(7) as IntegerMember).defaultValue) | ||
assertEquals(1.0f, (struct.members.get(8) as FloatMember).defaultValue, 0.001f) | ||
assertEquals(2.0f, (struct.members.get(9) as FloatMember).defaultValue, 0.001f) | ||
} | ||
|
||
} |
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
Oops, something went wrong.