summaryrefslogtreecommitdiff
path: root/spec/ruby/core/array/pack/s_spec.rb
blob: 4212d6a0b14b6e5fbe20d65faf1fd4f93aa32959 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
require_relative '../../../spec_helper'
require_relative '../fixtures/classes'
require_relative 'shared/basic'
require_relative 'shared/numeric_basic'
require_relative 'shared/integer'

describe "Array#pack with format 'S'" do
  it_behaves_like :array_pack_basic, 'S'
  it_behaves_like :array_pack_basic_non_float, 'S'
  it_behaves_like :array_pack_arguments, 'S'
  it_behaves_like :array_pack_numeric_basic, 'S'
  it_behaves_like :array_pack_integer, 'S'
end

describe "Array#pack with format 's'" do
  it_behaves_like :array_pack_basic, 's'
  it_behaves_like :array_pack_basic_non_float, 's'
  it_behaves_like :array_pack_arguments, 's'
  it_behaves_like :array_pack_numeric_basic, 's'
  it_behaves_like :array_pack_integer, 's'
end

describe "Array#pack with format 'S'" do
  describe "with modifier '<'" do
    it_behaves_like :array_pack_16bit_le, 'S<'
  end

  describe "with modifier '<' and '_'" do
    it_behaves_like :array_pack_16bit_le, 'S<_'
    it_behaves_like :array_pack_16bit_le, 'S_<'
  end

  describe "with modifier '<' and '!'" do
    it_behaves_like :array_pack_16bit_le, 'S<!'
    it_behaves_like :array_pack_16bit_le, 'S!<'
  end

  describe "with modifier '>'" do
    it_behaves_like :array_pack_16bit_be, 'S>'
  end

  describe "with modifier '>' and '_'" do
    it_behaves_like :array_pack_16bit_be, 'S>_'
    it_behaves_like :array_pack_16bit_be, 'S_>'
  end

  describe "with modifier '>' and '!'" do
    it_behaves_like :array_pack_16bit_be, 'S>!'
    it_behaves_like :array_pack_16bit_be, 'S!>'
  end
end

describe "Array#pack with format 's'" do
  describe "with modifier '<'" do
    it_behaves_like :array_pack_16bit_le, 's<'
  end

  describe "with modifier '<' and '_'" do
    it_behaves_like :array_pack_16bit_le, 's<_'
    it_behaves_like :array_pack_16bit_le, 's_<'
  end

  describe "with modifier '<' and '!'" do
    it_behaves_like :array_pack_16bit_le, 's<!'
    it_behaves_like :array_pack_16bit_le, 's!<'
  end

  describe "with modifier '>'" do
    it_behaves_like :array_pack_16bit_be, 's>'
  end

  describe "with modifier '>' and '_'" do
    it_behaves_like :array_pack_16bit_be, 's>_'
    it_behaves_like :array_pack_16bit_be, 's_>'
  end

  describe "with modifier '>' and '!'" do
    it_behaves_like :array_pack_16bit_be, 's>!'
    it_behaves_like :array_pack_16bit_be, 's!>'
  end
end

little_endian do
  describe "Array#pack with format 'S'" do
    it_behaves_like :array_pack_16bit_le, 'S'
  end

  describe "Array#pack with format 'S' with modifier '_'" do
    it_behaves_like :array_pack_16bit_le, 'S_'
  end

  describe "Array#pack with format 'S' with modifier '!'" do
    it_behaves_like :array_pack_16bit_le, 'S!'
  end

  describe "Array#pack with format 's'" do
    it_behaves_like :array_pack_16bit_le, 's'
  end

  describe "Array#pack with format 's' with modifier '_'" do
    it_behaves_like :array_pack_16bit_le, 's_'
  end

  describe "Array#pack with format 's' with modifier '!'" do
    it_behaves_like :array_pack_16bit_le, 's!'
  end
end

big_endian do
  describe "Array#pack with format 'S'" do
    it_behaves_like :array_pack_16bit_be, 'S'
  end

  describe "Array#pack with format 'S' with modifier '_'" do
    it_behaves_like :array_pack_16bit_be, 'S_'
  end

  describe "Array#pack with format 'S' with modifier '!'" do
    it_behaves_like :array_pack_16bit_be, 'S!'
  end

  describe "Array#pack with format 's'" do
    it_behaves_like :array_pack_16bit_be, 's'
  end

  describe "Array#pack with format 's' with modifier '_'" do
    it_behaves_like :array_pack_16bit_be, 's_'
  end

  describe "Array#pack with format 's' with modifier '!'" do
    it_behaves_like :array_pack_16bit_be, 's!'
  end
end