Permalink
Browse files

test: add type "alignment" tests

  • Loading branch information...
1 parent e41d4ad commit 27a74600eccb6d1171159e5fca51d61e64353ab7 @TooTallNate committed May 30, 2012
Showing with 32 additions and 17 deletions.
  1. +3 −0 lib/ref.js
  2. +0 −17 test/sizeof.js
  3. +29 −0 test/types.js
View
@@ -522,6 +522,9 @@ Object.keys(exports.alignof).forEach(function (name) {
assert(exports.types[name].alignment > 0)
})
+// make the `Utf8String` type have the correct 'alignment' property
+exports.types.Utf8String.alignment = exports.alignof.pointer
+
/**
* NULL_POINTER is essentially:
View
@@ -1,17 +0,0 @@
-
-var assert = require('assert')
-var ref = require('../')
-
-describe('sizeof', function () {
-
- Object.keys(ref.sizeof).forEach(function (type) {
-
- it('sizeof(' + type + ') should be >= 1', function () {
- var size = ref.sizeof[type]
- assert.equal('number', typeof size)
- assert(size >= 1)
- })
-
- })
-
-})
View
@@ -0,0 +1,29 @@
+
+var assert = require('assert')
+var ref = require('../')
+
+describe('types', function () {
+
+ describe('size', function () {
+ Object.keys(ref.types).forEach(function (name) {
+ if (name === 'void') return
+ it('sizeof(' + name + ') should be >= 1', function () {
+ var type = ref.types[name]
+ assert.equal('number', typeof type.size)
+ assert(type.size >= 1)
+ })
+ })
+ })
+
+ describe('alignment', function () {
+ Object.keys(ref.types).forEach(function (name) {
+ if (name === 'void') return
+ it('alignof(' + name + ') should be >= 1', function () {
+ var type = ref.types[name]
+ assert.equal('number', typeof type.alignment)
+ assert(type.alignment >= 1)
+ })
+ })
+ })
+
+})

0 comments on commit 27a7460

Please sign in to comment.