<commit_before>var ctype = require('ctype')
  , fields = require('../lib/messages/fields')

describe('Check type', function() {
  it('should identify primitive types', function() {
    expect(fields.isPrimitiveType('bool')).toEqual(true)
    expect(fields.isPrimitiveType('int8')).toEqual(true)
    expect(fields.isPrimitiveType('uint8')).toEqual(true)
    expect(fields.isPrimitiveType('int16')).toEqual(true)
    expect(fields.isPrimitiveType('uint16')).toEqual(true)
    expect(fields.isPrimitiveType('int32')).toEqual(true)
    expect(fields.isPrimitiveType('uint32')).toEqual(true)
    expect(fields.isPrimitiveType('float32')).toEqual(true)
    expect(fields.isPrimitiveType('float64')).toEqual(true)
    expect(fields.isPrimitiveType('string')).toEqual(true)

    // Arrays are not primitives
    expect(fields.isPrimitiveType('bool[]')).toEqual(false)
    expect(fields.isPrimitiveType('float32[]')).toEqual(false)
    expect(fields.isPrimitiveType('float64[]')).toEqual(false)
    expect(fields.isPrimitiveType('std_msgs/String[]')).toEqual(false)

    // Message Types are not primitives
    expect(fields.isPrimitiveType('std_msgs/String')).toEqual(false)
    expect(fields.isPrimitiveType('Header')).toEqual(false)
    expect(fields.isPrimitiveType('geometry_msgs/Twist')).toEqual(false)
    expect(fields.isPrimitiveType('Point32')).toEqual(false)
    expect(fields.isPrimitiveType('String')).toEqual(false)
  })

  it('should identify arrays', function() {
    expect(fields.isArray('bool[]')).toEqual(true)
    expect(fields.isArray('int8[]')).toEqual(true)
    expect(fields.isArray('float32[]')).toEqual(true)
    expect(fields.isArray('std_msgs/String[]')).toEqual(true)
    expect(fields.isArray('geometry_msgs/Twist[]')).toEqual(true)
    expect(fields.isArray('Point32[]')).toEqual(true)

    expect(fields.isArray('bool')).toEqual(false)
    expect(fields.isArray('float32')).toEqual(false)
    expect(fields.isArray('std_msgs/String')).toEqual(false)
    expect(fields.isArray('Header')).toEqual(false)
    expect(fields.isArray('Point32')).toEqual(false)
  })

  it('should identify message types', function() {
    expect(fields.isMessageType('std_msgs/String')).toEqual(true)
    expect(fields.isMessageType('geometry_msgs/String')).toEqual(true)
    expect(fields.isMessageType('String')).toEqual(true)
    expect(fields.isMessageType('Header')).toEqual(true)
    expect(fields.isMessageType('Point32')).toEqual(true)

    expect(fields.isMessageType('bool')).toEqual(false)
    expect(fields.isMessageType('float32')).toEqual(false)
    expect(fields.isMessageType('string')).toEqual(false)
    expect(fields.isMessageType('bool[]')).toEqual(false)
    expect(fields.isMessageType('float32[]')).toEqual(false)
    expect(fields.isMessageType('std_msgs/String[]')).toEqual(false)
    expect(fields.isMessageType('Point32[]')).toEqual(false)
  })
})

describe('Parse fields', function() {
  it('should work with bools', function() {
    var boolField = fields.parseField('bool', '1')
    expect(boolField).toEqual(true)
    boolField = fields.parseField('bool', '0')
    expect(boolField).toEqual(false)<commit_msg>Error identifying arrays with size as arrays.<commit_after>var ctype = require('ctype')
  , fields = require('../lib/messages/fields')

describe('Check type', function() {
  it('should identify primitive types', function() {
    expect(fields.isPrimitiveType('bool')).toEqual(true)
    expect(fields.isPrimitiveType('int8')).toEqual(true)
    expect(fields.isPrimitiveType('uint8')).toEqual(true)
    expect(fields.isPrimitiveType('int16')).toEqual(true)
    expect(fields.isPrimitiveType('uint16')).toEqual(true)
    expect(fields.isPrimitiveType('int32')).toEqual(true)
    expect(fields.isPrimitiveType('uint32')).toEqual(true)
    expect(fields.isPrimitiveType('float32')).toEqual(true)
    expect(fields.isPrimitiveType('float64')).toEqual(true)
    expect(fields.isPrimitiveType('string')).toEqual(true)

    // Arrays are not primitives
    expect(fields.isPrimitiveType('bool[]')).toEqual(false)
    expect(fields.isPrimitiveType('float32[]')).toEqual(false)
    expect(fields.isPrimitiveType('float64[]')).toEqual(false)
    expect(fields.isPrimitiveType('float64[36]')).toEqual(false)
    expect(fields.isPrimitiveType('std_msgs/String[]')).toEqual(false)

    // Message Types are not primitives
    expect(fields.isPrimitiveType('std_msgs/String')).toEqual(false)
    expect(fields.isPrimitiveType('Header')).toEqual(false)
    expect(fields.isPrimitiveType('geometry_msgs/Twist')).toEqual(false)
    expect(fields.isPrimitiveType('Point32')).toEqual(false)
    expect(fields.isPrimitiveType('String')).toEqual(false)
  })

  it('should identify arrays', function() {
    expect(fields.isArray('bool[]')).toEqual(true)
    expect(fields.isArray('int8[]')).toEqual(true)
    expect(fields.isArray('float32[]')).toEqual(true)
    expect(fields.isArray('float64[36]')).toEqual(true)
    expect(fields.isArray('std_msgs/String[]')).toEqual(true)
    expect(fields.isArray('geometry_msgs/Twist[]')).toEqual(true)
    expect(fields.isArray('Point32[]')).toEqual(true)

    expect(fields.isArray('bool')).toEqual(false)
    expect(fields.isArray('float32')).toEqual(false)
    expect(fields.isArray('std_msgs/String')).toEqual(false)
    expect(fields.isArray('Header')).toEqual(false)
    expect(fields.isArray('Point32')).toEqual(false)
  })

  it('should identify message types', function() {
    expect(fields.isMessageType('std_msgs/String')).toEqual(true)
    expect(fields.isMessageType('geometry_msgs/String')).toEqual(true)
    expect(fields.isMessageType('String')).toEqual(true)
    expect(fields.isMessageType('Header')).toEqual(true)
    expect(fields.isMessageType('Point32')).toEqual(true)

    expect(fields.isMessageType('bool')).toEqual(false)
    expect(fields.isMessageType('float32')).toEqual(false)
    expect(fields.isMessageType('string')).toEqual(false)
    expect(fields.isMessageType('bool[]')).toEqual(false)
    expect(fields.isMessageType('float32[]')).toEqual(false)
    expect(fields.isMessageType('float64[36]')).toEqual(false)
    expect(fields.isMessageType('std_msgs/String[]')).toEqual(false)
    expect(fields.isMessageType('Point32[]')).toEqual(false)
  })
})

describe('Parse fields', function() {
  it('should work with bools', function() {
    var boolField = fields.parseField('bool', '1')
    expect(boolField).toEqual(true)
    boolField = fields.parseField('bool', '0')
    expect(boolField).toEqual(false)
{'fraction_non_alphanumeric': 0.17743921206525085, 'fraction_numerical': 0.013850415512465374, 'mean_word_length': 6.343502824858757, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5789727', 'n_tokens_mistral': 1949, 'n_tokens_neox': 2125, 'n_words': 188}