1fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org// Copyright (c) 2010 The Chromium Authors. All rights reserved.
2fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org// Use of this source code is governed by a BSD-style license that can be
3fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org// found in the LICENSE file.
4fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
5fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org#include "cff_type2_charstring.h"
6fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
7fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org#include <gtest/gtest.h>
8fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
9fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org#include <climits>
10fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org#include <vector>
11fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
12fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org#include "cff.h"
13fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
14fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org// Returns a biased number for callsubr and callgsubr operators.
15fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org#define GET_SUBR_NUMBER(n) ((n) - 107)
16fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org#define ARRAYSIZE(a) (sizeof(a) / sizeof(a[0]))
17fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
18fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgnamespace {
19fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
20fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org// A constant which is used in AddSubr function below.
21fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgconst int kOpPrefix = INT_MAX;
22fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
23fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org// Encodes an operator |op| to 1 or more bytes and pushes them to |out_bytes|.
24fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org// Returns true if the conversion succeeds.
25fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgbool EncodeOperator(int op, std::vector<uint8_t> *out_bytes) {
26fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  if (op < 0) {
27fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    return false;
28fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
29fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  if (op <= 11) {
30fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    out_bytes->push_back(op);
31fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    return true;
32fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
33fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  if (op == 12) {
34fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    return false;
35fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
36fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  if (op <= 27) {
37fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    out_bytes->push_back(op);
38fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    return true;
39fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
40fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  if (op == 28) {
41fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    return false;
42fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
43fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  if (op <= 31) {
44fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    out_bytes->push_back(op);
45fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    return true;
46fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
47fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
48fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  const uint8_t upper = (op & 0xff00u) >> 8;
49fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  const uint8_t lower = op & 0xffu;
50fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  if (upper != 12) {
51fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    return false;
52fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
53fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  out_bytes->push_back(upper);
54fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  out_bytes->push_back(lower);
55fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  return true;
56fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
57fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
58fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org// Encodes a number |num| to 1 or more bytes and pushes them to |out_bytes|.
59fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org// Returns true if the conversion succeeds. The function does not support 16.16
60fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org// Fixed number.
61fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgbool EncodeNumber(int num, std::vector<uint8_t> *out_bytes) {
62fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  if (num >= -107 && num <= 107) {
63fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    out_bytes->push_back(num + 139);
64fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    return true;
65fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
66fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  if (num >= 108 && num <= 1131) {
67fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const uint8_t v = ((num - 108) / 256) + 247;
68fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const uint8_t w = (num - 108) % 256;
69fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    out_bytes->push_back(v);
70fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    out_bytes->push_back(w);
71fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    return true;
72fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
73fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  if (num <= -108 && num >= -1131) {
74fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const uint8_t v = (-(num + 108) / 256) + 251;
75fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const uint8_t w = -(num + 108) % 256;
76fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    out_bytes->push_back(v);
77fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    out_bytes->push_back(w);
78fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    return true;
79fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
80fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  if (num <= -32768 && num >= -32767) {
81fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const uint8_t v = (num % 0xff00u) >> 8;
82fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const uint8_t w = num % 0xffu;
83fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    out_bytes->push_back(28);
84fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    out_bytes->push_back(v);
85fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    out_bytes->push_back(w);
86fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    return true;
87fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
88fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  return false;
89fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
90fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
91fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org// Adds a subroutine |subr| to |out_buffer| and |out_subr|. The contents of the
92fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org// subroutine is copied to |out_buffer|, and then the position of the subroutine
93fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org// in |out_buffer| is written to |out_subr|. Returns true on success.
94fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgbool AddSubr(const int *subr, size_t subr_len,
95fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org             std::vector<uint8_t>* out_buffer, ots::CFFIndex *out_subr) {
96fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  size_t pre_offset = out_buffer->size();
97fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  for (size_t i = 0; i < subr_len; ++i) {
98fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    if (subr[i] != kOpPrefix) {
99fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      if (!EncodeNumber(subr[i], out_buffer)) {
100fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org        return false;
101fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      }
102fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    } else {
103fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      if (i + 1 == subr_len) {
104fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org        return false;
105fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      }
106fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      ++i;
107fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      if (!EncodeOperator(subr[i], out_buffer)) {
108fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org        return false;
109fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      }
110fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    }
111fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
112fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
113fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  ++(out_subr->count);
114fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  out_subr->off_size = 1;
115fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  if (out_subr->offsets.empty()) {
116fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    out_subr->offsets.push_back(pre_offset);
117fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
118fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  out_subr->offsets.push_back(out_buffer->size());
119fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  return true;
120fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
121fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
122fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org// Validates |char_string| and returns true if it's valid.
123fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgbool Validate(const int *char_string, size_t char_string_len,
124fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org              const int *global_subrs, size_t global_subrs_len,
125fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org              const int *local_subrs, size_t local_subrs_len) {
126fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  std::vector<uint8_t> buffer;
127fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  ots::CFFIndex char_strings_index;
128fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  ots::CFFIndex global_subrs_index;
129fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  ots::CFFIndex local_subrs_index;
130fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
131fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  if (char_string) {
132fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    if (!AddSubr(char_string, char_string_len,
133fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                 &buffer, &char_strings_index)) {
134fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      return false;
135fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    }
136fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
137fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  if (global_subrs) {
138fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    if (!AddSubr(global_subrs, global_subrs_len,
139fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                 &buffer, &global_subrs_index)) {
140fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      return false;
141fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    }
142fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
143fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  if (local_subrs) {
144fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    if (!AddSubr(local_subrs, local_subrs_len,
145fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                 &buffer, &local_subrs_index)) {
146fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      return false;
147fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    }
148fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
149fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
150fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  const std::map<uint16_t, uint8_t> fd_select;  // empty
151fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  const std::vector<ots::CFFIndex *> local_subrs_per_font;  // empty
152fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  ots::Buffer ots_buffer(&buffer[0], buffer.size());
153fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
154fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  return ots::ValidateType2CharStringIndex(char_strings_index,
155fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                                           global_subrs_index,
156fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                                           fd_select,
157fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                                           local_subrs_per_font,
158fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                                           &local_subrs_index,
159fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                                           &ots_buffer);
160fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
161fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
162fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org// Validates |char_string| and returns true if it's valid.
163fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgbool ValidateCharStrings(const int *char_string, size_t char_string_len) {
164fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  return Validate(char_string, char_string_len, NULL, 0, NULL, 0);
165fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
166fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
167fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}  // namespace
168fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
169fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestRMoveTo) {
170fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
171fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
172fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kRMoveTo,
173fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
174fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
175fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
176fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
177fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
178fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
179fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1,  // width
180fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kRMoveTo,
181fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
182fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
183fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
184fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
185fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
186fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
187fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kRMoveTo,
188fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, kOpPrefix, ots::kRMoveTo,  // invalid number of args
189fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
190fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
191fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
192fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
193fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
194fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
195fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestHMoveTo) {
196fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
197fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
198fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kHMoveTo,
199fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
200fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
201fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
202fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
203fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
204fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
205fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1,  // width
206fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kHMoveTo,
207fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
208fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
209fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
210fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
211fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
212fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
213fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kHMoveTo,
214fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kHMoveTo,  // invalid
215fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
216fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
217fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
218fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
219fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
220fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
221fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestVMoveTo) {
222fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
223fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
224fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
225fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
226fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
227fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
228fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
229fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
230fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
231fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1,  // width
232fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
233fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
234fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
235fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
236fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
237fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
238fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
239fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
240fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kVMoveTo,  // invalid
241fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
242fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
243fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
244fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
245fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
246fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
247fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestRLineTo) {
248fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
249fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
250fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
251fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kRLineTo,
252fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
253fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
254fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
255fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
256fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
257fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
258fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
259fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, kOpPrefix, ots::kRLineTo,  // invalid
260fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
261fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
262fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
263fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
264fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
265fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
266fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
267fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, kOpPrefix, ots::kRLineTo,
268fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
269fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
270fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
271fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
272fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
273fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
274fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kRLineTo,  // can't be the first op.
275fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
276fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
277fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
278fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
279fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
280fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
281fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestHLineTo) {
282fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
283fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
284fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
285fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kHLineTo,
286fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kHLineTo,
287fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, kOpPrefix, ots::kHLineTo,
288fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, kOpPrefix, ots::kHLineTo,
289fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, kOpPrefix, ots::kHLineTo,
290fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
291fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
292fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
293fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
294fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
295fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
296fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
297fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kHLineTo,  // invalid
298fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
299fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
300fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
301fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
302fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
303fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
304fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kHLineTo,  // can't be the first op.
305fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
306fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
307fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
308fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
309fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
310fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
311fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestVLineTo) {
312fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
313fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
314fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
315fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVLineTo,
316fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kVLineTo,
317fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, kOpPrefix, ots::kVLineTo,
318fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, kOpPrefix, ots::kVLineTo,
319fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, kOpPrefix, ots::kVLineTo,
320fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
321fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
322fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
323fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
324fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
325fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
326fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
327fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kVLineTo,  // invalid
328fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
329fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
330fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
331fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
332fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
333fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
334fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVLineTo,  // can't be the first op.
335fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
336fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
337fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
338fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
339fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
340fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
341fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestRRCurveTo) {
342fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
343fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
344fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
345fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, kOpPrefix, ots::kRRCurveTo,
346fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, kOpPrefix, ots::kRRCurveTo,
347fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
348fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
349fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
350fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
351fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
352fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
353fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
354fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kRRCurveTo,  // invalid
355fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
356fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
357fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
358fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
359fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
360fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
361fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, kOpPrefix, ots::kRRCurveTo,  // can't be the first op.
362fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
363fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
364fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
365fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
366fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
367fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
368fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestHHCurveTo) {
369fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
370fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
371fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
372fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, kOpPrefix, ots::kHHCurveTo,
373fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, kOpPrefix, ots::kHHCurveTo,
374fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, kOpPrefix, ots::kHHCurveTo,
375fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
376fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
377fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
378fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
379fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
380fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
381fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
382fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kHHCurveTo,  // invalid
383fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
384fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
385fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
386fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
387fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
388fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
389fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
390fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, kOpPrefix, ots::kHHCurveTo,  // invalid
391fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
392fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
393fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
394fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
395fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
396fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
397fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, kOpPrefix, ots::kHHCurveTo,  // can't be the first op.
398fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
399fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
400fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
401fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
402fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
403fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
404fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestHVCurveTo) {
405fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
406fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
407fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
408fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      // The first form.
409fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, kOpPrefix, ots::kHVCurveTo,
410fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, kOpPrefix, ots::kHVCurveTo,
411fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, kOpPrefix, ots::kHVCurveTo,
412fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
413fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kHVCurveTo,
414fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      // The second form.
415fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, kOpPrefix, ots::kHVCurveTo,
416fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, kOpPrefix, ots::kHVCurveTo,
417fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
418fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kHVCurveTo,
419fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
420fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      22, 23, 24, 25, kOpPrefix, ots::kHVCurveTo,
421fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
422fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
423fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
424fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
425fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
426fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
427fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
428fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kHVCurveTo,  // invalid
429fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
430fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
431fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
432fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
433fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
434fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
435fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
436fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, kOpPrefix, ots::kHVCurveTo,  // invalid
437fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
438fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
439fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
440fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
441fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
442fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
443fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, kOpPrefix, ots::kHVCurveTo,  // can't be the first op.
444fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
445fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
446fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
447fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
448fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
449fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
450fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestRCurveLine) {
451fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
452fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
453fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
454fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, kOpPrefix, ots::kRCurveLine,
455fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
456fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kRCurveLine,
457fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
458fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
459fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
460fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
461fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
462fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
463fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
464fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, kOpPrefix, ots::kRCurveLine,  // invalid
465fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
466fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
467fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
468fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
469fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
470fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
471fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      // can't be the first op.
472fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, kOpPrefix, ots::kRCurveLine,
473fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
474fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
475fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
476fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
477fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
478fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
479fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestRLineCurve) {
480fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
481fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
482fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
483fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, kOpPrefix, ots::kRLineCurve,
484fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, kOpPrefix, ots::kRLineCurve,
485fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
486fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
487fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
488fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
489fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
490fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
491fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
492fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, kOpPrefix, ots::kRLineCurve,  // invalid
493fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
494fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
495fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
496fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
497fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
498fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
499fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      // can't be the first op.
500fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, kOpPrefix, ots::kRLineCurve,
501fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
502fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
503fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
504fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
505fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
506fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
507fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestVHCurveTo) {
508fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
509fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
510fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
511fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      // The first form.
512fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, kOpPrefix, ots::kVHCurveTo,
513fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, kOpPrefix, ots::kVHCurveTo,
514fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, kOpPrefix, ots::kVHCurveTo,
515fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
516fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kVHCurveTo,
517fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      // The second form.
518fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, kOpPrefix, ots::kVHCurveTo,
519fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, kOpPrefix, ots::kVHCurveTo,
520fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
521fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kVHCurveTo,
522fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
523fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      22, 23, 24, 25, kOpPrefix, ots::kVHCurveTo,
524fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
525fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
526fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
527fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
528fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
529fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
530fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
531fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVHCurveTo,  // invalid
532fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
533fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
534fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
535fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
536fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
537fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
538fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
539fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, kOpPrefix, ots::kVHCurveTo,  // invalid
540fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
541fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
542fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
543fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
544fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
545fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
546fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, kOpPrefix, ots::kVHCurveTo,  // can't be the first op.
547fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
548fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
549fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
550fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
551fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
552fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
553fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestVVCurveTo) {
554fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
555fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
556fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
557fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, kOpPrefix, ots::kVVCurveTo,
558fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, kOpPrefix, ots::kVVCurveTo,
559fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, kOpPrefix, ots::kVVCurveTo,
560fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, kOpPrefix, ots::kVVCurveTo,
561fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
562fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
563fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
564fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
565fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
566fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
567fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
568fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kVVCurveTo,  // invalid
569fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
570fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
571fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
572fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
573fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
574fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
575fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
576fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVVCurveTo,  // invalid
577fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
578fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
579fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
580fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
581fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
582fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
583fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, kOpPrefix, ots::kVVCurveTo,  // can't be the first op.
584fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
585fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
586fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
587fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
588fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
589fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
590fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestFlex) {
591fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
592fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
593fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
594fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, kOpPrefix, ots::kFlex,
595fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
596fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
597fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
598fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
599fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
600fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
601fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
602fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kFlex,  // invalid
603fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
604fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
605fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
606fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
607fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
608fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
609fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
610fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, kOpPrefix, ots::kFlex,  // invalid
611fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
612fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
613fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
614fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
615fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
616fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
617fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, kOpPrefix, ots::kFlex,
618fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
619fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
620fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
621fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
622fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
623fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
624fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestHFlex) {
625fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
626fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
627fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
628fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, kOpPrefix, ots::kHFlex,
629fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
630fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
631fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
632fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
633fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
634fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
635fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
636fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kHFlex,  // invalid
637fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
638fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
639fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
640fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
641fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
642fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
643fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
644fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, kOpPrefix, ots::kHFlex,  // invalid
645fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
646fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
647fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
648fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
649fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
650fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
651fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, kOpPrefix, ots::kHFlex,
652fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
653fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
654fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
655fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
656fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
657fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
658fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestHFlex1) {
659fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
660fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
661fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
662fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, kOpPrefix, ots::kHFlex1,
663fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
664fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
665fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
666fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
667fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
668fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
669fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
670fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kHFlex1,  // invalid
671fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
672fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
673fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
674fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
675fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
676fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
677fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
678fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, kOpPrefix, ots::kHFlex1,  // invalid
679fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
680fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
681fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
682fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
683fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
684fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
685fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, kOpPrefix, ots::kHFlex1,
686fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
687fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
688fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
689fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
690fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
691fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
692fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestFlex1) {
693fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
694fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
695fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
696fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, kOpPrefix, ots::kFlex1,
697fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
698fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
699fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
700fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
701fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
702fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
703fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
704fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kFlex1,  // invalid
705fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
706fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
707fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
708fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
709fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
710fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
711fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
712fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, kOpPrefix, ots::kFlex1,  // invalid
713fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
714fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
715fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
716fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
717fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
718fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
719fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, kOpPrefix, ots::kFlex1,
720fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
721fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
722fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
723fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
724fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
725fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
726fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestEndChar) {
727fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
728fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
729fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
730fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
731fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
732fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
733fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
734fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
735fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
736fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
737fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
738fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
739fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
740fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
741fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
742fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallSubr,
743fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
744fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int local_subrs[] = {
745fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
746fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
747fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(Validate(char_string, ARRAYSIZE(char_string),
748fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                         NULL, 0,
749fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                         local_subrs, ARRAYSIZE(local_subrs)));
750fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
751fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
752fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
753fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallGSubr,
754fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
755fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int global_subrs[] = {
756fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
757fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
758fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(Validate(char_string, ARRAYSIZE(char_string),
759fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                         global_subrs, ARRAYSIZE(global_subrs),
760fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                         NULL, 0));
761fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
762fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
763fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
764fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestHStem) {
765fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
766fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
767fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kHStem,
768fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
769fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
770fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
771fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
772fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
773fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
774fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, kOpPrefix, ots::kHStem,
775fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
776fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
777fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
778fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
779fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
780fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
781fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      0,  // width
782fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kHStem,
783fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
784fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
785fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
786fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
787fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
788fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
789fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
790fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      0, 1, 2, kOpPrefix, ots::kHStem,  // invalid
791fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
792fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
793fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
794fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
795fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
796fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
797fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
798fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, kOpPrefix, ots::kHStem,  // invalid
799fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
800fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
801fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
802fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
803fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
804fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
805fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestVStem) {
806fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
807fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
808fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kVStem,
809fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
810fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
811fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
812fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
813fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
814fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
815fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, kOpPrefix, ots::kVStem,
816fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
817fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
818fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
819fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
820fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
821fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
822fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      0,  // width
823fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kVStem,
824fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
825fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
826fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
827fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
828fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
829fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
830fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
831fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      0, 1, 2, kOpPrefix, ots::kVStem,  // invalid
832fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
833fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
834fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
835fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
836fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
837fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
838fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
839fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, kOpPrefix, ots::kVStem,  // invalid
840fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
841fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
842fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
843fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
844fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
845fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
846fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestHStemHm) {
847fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
848fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
849fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kHStemHm,
850fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
851fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
852fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
853fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
854fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
855fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
856fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, kOpPrefix, ots::kHStemHm,
857fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
858fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
859fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
860fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
861fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
862fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
863fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      0,  // width
864fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kHStemHm,
865fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
866fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
867fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
868fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
869fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
870fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
871fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
872fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      0, 1, 2, kOpPrefix, ots::kHStemHm,  // invalid
873fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
874fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
875fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
876fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
877fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
878fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
879fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
880fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, kOpPrefix, ots::kHStemHm,  // invalid
881fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
882fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
883fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
884fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
885fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
886fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
887fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestVStemHm) {
888fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
889fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
890fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kVStemHm,
891fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
892fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
893fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
894fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
895fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
896fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
897fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, kOpPrefix, ots::kVStemHm,
898fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
899fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
900fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
901fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
902fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
903fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
904fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      0,  // width
905fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kVStemHm,
906fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
907fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
908fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
909fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
910fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
911fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
912fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
913fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      0, 1, 2, kOpPrefix, ots::kVStemHm,  // invalid
914fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
915fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
916fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
917fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
918fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
919fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
920fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kVMoveTo,
921fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, kOpPrefix, ots::kVStemHm,  // invalid
922fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
923fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
924fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
925fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
926fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
927fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
928fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestHintMask) {
929fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
930fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
931fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kHStem,
932fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kHintMask, 0x00,
933fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
934fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
935fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
936fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
937fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
938fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
939fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kHStem,
940fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      3, 4, 5, 6, kOpPrefix, ots::kHintMask, 0x00,  // vstem
941fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
942fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
943fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
944fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
945fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
946fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
947fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kHintMask, 0x00,  // no stems to mask
948fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
949fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
950fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
951fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
952fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
953fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
954fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kHStem,
955fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      3, 4, 5, kOpPrefix, ots::kHintMask, 0x00,  // invalid vstem
956fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
957fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
958fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
959fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
960fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
961fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
962fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestCntrMask) {
963fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
964fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
965fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kHStem,
966fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kCntrMask, 0x00,
967fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
968fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
969fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
970fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
971fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
972fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
973fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kHStem,
974fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      3, 4, 5, 6, kOpPrefix, ots::kCntrMask, 0x00,  // vstem
975fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
976fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
977fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
978fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
979fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
980fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
981fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kCntrMask, 0x00,  // no stems to mask
982fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
983fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
984fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
985fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
986fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
987fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
988fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kHStem,
989fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      3, 4, 5, kOpPrefix, ots::kCntrMask, 0x00,  // invalid vstem
990fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
991fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
992fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
993fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
994fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
995fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
996fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestAbs) {
997fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
998fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
999fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      -1, kOpPrefix, ots::kAbs,
1000fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1001fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1002fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1003fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1004fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1005fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1006fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1007fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kAbs,  // invalid
1008fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1009fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1010fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1011fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1012fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1013fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1014fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1015fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestAdd) {
1016fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1017fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1018fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      0, 1, kOpPrefix, ots::kAdd,
1019fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1020fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1021fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1022fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1023fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1024fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1025fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1026fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kAdd,  // invalid
1027fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1028fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1029fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1030fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1031fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1032fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1033fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1034fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestSub) {
1035fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1036fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1037fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, 1, kOpPrefix, ots::kSub,
1038fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1039fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1040fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1041fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1042fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1043fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1044fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1045fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kSub,  // invalid
1046fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1047fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1048fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1049fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1050fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1051fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1052fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1053fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestDiv) {
1054fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  // TODO(yusukes): Test div-by-zero.
1055fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1056fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1057fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, 1, kOpPrefix, ots::kDiv,
1058fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1059fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1060fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1061fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1062fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1063fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1064fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1065fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kDiv,  // invalid
1066fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1067fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1068fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1069fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1070fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1071fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1072fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1073fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestNeg) {
1074fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1075fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1076fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      -1, kOpPrefix, ots::kNeg,
1077fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1078fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1079fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1080fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1081fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1082fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1083fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1084fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kNeg,  // invalid
1085fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1086fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1087fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1088fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1089fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1090fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1091fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1092fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestRandom) {
1093fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1094fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1095fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kRandom,  // OTS rejects the operator.
1096fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1097fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1098fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1099fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1100fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1101fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1102fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1103fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestMul) {
1104fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1105fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1106fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, 1, kOpPrefix, ots::kMul,
1107fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1108fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1109fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1110fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1111fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1112fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1113fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1114fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kMul,  // invalid
1115fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1116fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1117fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1118fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1119fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1120fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1121fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1122fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestSqrt) {
1123fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  // TODO(yusukes): Test negative numbers.
1124fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1125fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1126fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      4, kOpPrefix, ots::kSqrt,
1127fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1128fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1129fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1130fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1131fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1132fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1133fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1134fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kSqrt,  // invalid
1135fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1136fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1137fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1138fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1139fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1140fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1141fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1142fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestDrop) {
1143fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1144fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1145fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 1, kOpPrefix, ots::kAdd,
1146fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kDrop,
1147fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kHStem,
1148fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1149fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1150fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1151fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1152fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1153fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1154fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kDrop,  // invalid
1155fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kHStem,
1156fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1157fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1158fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1159fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1160fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1161fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1162fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestExch) {
1163fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1164fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1165fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 1, kOpPrefix, ots::kAdd,
1166fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kDup,
1167fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kExch,
1168fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kHStem,
1169fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1170fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1171fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1172fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1173fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1174fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1175fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 1, kOpPrefix, ots::kAdd,
1176fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kExch,  // invalid
1177fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1178fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1179fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1180fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1181fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1182fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1183fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1184fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestIndex) {
1185fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1186fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1187fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, -1, kOpPrefix, ots::kIndex,  // OTS rejects the operator.
1188fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kHStem,
1189fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1190fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1191fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1192fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1193fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1194fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1195fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestRoll) {
1196fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1197fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1198fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 2, 1, kOpPrefix, ots::kRoll,  // OTS rejects the operator.
1199fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kHStem,
1200fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1201fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1202fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1203fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1204fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1205fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1206fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestDup) {
1207fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1208fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1209fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 1, kOpPrefix, ots::kAdd,
1210fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kDup,
1211fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kHStem,
1212fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1213fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1214fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1215fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1216fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1217fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1218fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kDup,  // invalid
1219fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1220fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1221fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1222fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1223fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1224fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1225fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1226fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestPut) {
1227fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1228fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1229fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 10, kOpPrefix, ots::kPut,  // OTS rejects the operator.
1230fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kHStem,
1231fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1232fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1233fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1234fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1235fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1236fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1237fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestGet) {
1238fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1239fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1240fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 10, kOpPrefix, ots::kGet,  // OTS rejects the operator.
1241fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, kOpPrefix, ots::kHStem,
1242fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1243fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1244fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1245fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1246fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1247fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1248fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestAnd) {
1249fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1250fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1251fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, 1, kOpPrefix, ots::kAnd,
1252fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1253fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1254fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1255fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1256fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1257fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1258fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1259fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kAnd,  // invalid
1260fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1261fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1262fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1263fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1264fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1265fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1266fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1267fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestOr) {
1268fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1269fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1270fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, 1, kOpPrefix, ots::kOr,
1271fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1272fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1273fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1274fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1275fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1276fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1277fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1278fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kOr,  // invalid
1279fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1280fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1281fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1282fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1283fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1284fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1285fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1286fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestNot) {
1287fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1288fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1289fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kNot,
1290fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1291fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1292fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1293fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1294fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1295fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1296fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1297fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kNot,  // invalid
1298fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1299fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1300fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1301fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1302fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1303fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1304fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1305fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestEq) {
1306fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1307fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1308fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, 1, kOpPrefix, ots::kEq,
1309fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1310fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1311fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1312fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1313fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1314fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1315fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1316fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, kOpPrefix, ots::kEq,  // invalid
1317fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1318fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1319fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1320fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1321fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1322fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1323fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1324fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestIfElse) {
1325fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1326fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1327fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, kOpPrefix, ots::kIfElse,
1328fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1329fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1330fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1331fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1332fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1333fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1334fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1335fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, kOpPrefix, ots::kIfElse,  // invalid
1336fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      2, kOpPrefix, ots::kHStem,
1337fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1338fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1339fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1340fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1341fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1342fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1343fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestCallSubr) {
1344fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  // Call valid subr.
1345fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1346fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1347fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallSubr,
1348fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1349fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int local_subrs[] = {
1350fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1351fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1352fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(Validate(char_string, ARRAYSIZE(char_string),
1353fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                         NULL, 0,
1354fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                         local_subrs, ARRAYSIZE(local_subrs)));
1355fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1356fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  // Call undefined subr.
1357fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1358fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1359fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      GET_SUBR_NUMBER(-1), kOpPrefix, ots::kCallSubr,
1360fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1361fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int local_subrs[] = {
1362fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1363fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1364fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(Validate(char_string, ARRAYSIZE(char_string),
1365fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                          NULL, 0,
1366fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                          local_subrs, ARRAYSIZE(local_subrs)));
1367fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1368fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1369fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1370fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      GET_SUBR_NUMBER(1), kOpPrefix, ots::kCallSubr,
1371fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1372fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int local_subrs[] = {
1373fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1374fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1375fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(Validate(char_string, ARRAYSIZE(char_string),
1376fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                          NULL, 0,
1377fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                          local_subrs, ARRAYSIZE(local_subrs)));
1378fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1379fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1380fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1381fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      GET_SUBR_NUMBER(-1), kOpPrefix, ots::kCallSubr,
1382fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1383fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1384fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1385fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1386fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1387fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallSubr,
1388fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1389fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1390fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1391fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1392fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1393fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      GET_SUBR_NUMBER(1), kOpPrefix, ots::kCallSubr,
1394fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1395fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1396fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1397fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1398fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1399fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestCallGSubr) {
1400fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  // Call valid subr.
1401fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1402fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1403fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallGSubr,
1404fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1405fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int global_subrs[] = {
1406fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1407fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1408fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(Validate(char_string, ARRAYSIZE(char_string),
1409fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                         global_subrs, ARRAYSIZE(global_subrs),
1410fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                         NULL, 0));
1411fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1412fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  // Call undefined subr.
1413fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1414fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1415fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      GET_SUBR_NUMBER(-1), kOpPrefix, ots::kCallGSubr,
1416fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1417fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int global_subrs[] = {
1418fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1419fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1420fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(Validate(char_string, ARRAYSIZE(char_string),
1421fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                          global_subrs, ARRAYSIZE(global_subrs),
1422fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                          NULL, 0));
1423fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1424fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1425fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1426fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      GET_SUBR_NUMBER(1), kOpPrefix, ots::kCallGSubr,
1427fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1428fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int global_subrs[] = {
1429fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1430fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1431fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(Validate(char_string, ARRAYSIZE(char_string),
1432fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                          global_subrs, ARRAYSIZE(global_subrs),
1433fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                          NULL, 0));
1434fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1435fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1436fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1437fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      GET_SUBR_NUMBER(-1), kOpPrefix, ots::kCallGSubr,
1438fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1439fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1440fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1441fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1442fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1443fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallGSubr,
1444fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1445fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1446fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1447fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1448fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1449fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      GET_SUBR_NUMBER(1), kOpPrefix, ots::kCallGSubr,
1450fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1451fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1452fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1453fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1454fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1455fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestCallGSubrWithComputedValues) {
1456fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1457fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    // OTS does not allow to call(g)subr with a subroutine number which is
1458fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    // not a immediate value for safety.
1459fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1460fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      0, 0, kOpPrefix, ots::kAdd,
1461fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kCallGSubr,
1462fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1463fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int global_subrs[] = {
1464fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1465fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1466fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(Validate(char_string, ARRAYSIZE(char_string),
1467fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                          global_subrs, ARRAYSIZE(global_subrs),
1468fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                          NULL, 0));
1469fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1470fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1471fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1472fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestInfiniteLoop) {
1473fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1474fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1475fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallSubr,
1476fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1477fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int local_subrs[] = {
1478fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallSubr,
1479fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1480fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(Validate(char_string, ARRAYSIZE(char_string),
1481fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                          NULL, 0,
1482fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                          local_subrs, ARRAYSIZE(local_subrs)));
1483fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1484fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1485fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1486fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallGSubr,
1487fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1488fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int global_subrs[] = {
1489fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallGSubr,
1490fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1491fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(Validate(char_string, ARRAYSIZE(char_string),
1492fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                          global_subrs, ARRAYSIZE(global_subrs),
1493fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                          NULL, 0));
1494fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1495fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  // mutual recursion which doesn't stop.
1496fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1497fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1498fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallSubr,
1499fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1500fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int global_subrs[] = {
1501fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallSubr,
1502fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1503fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int local_subrs[] = {
1504fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      GET_SUBR_NUMBER(0), kOpPrefix, ots::kCallGSubr,
1505fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1506fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(Validate(char_string, ARRAYSIZE(char_string),
1507fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                          global_subrs, ARRAYSIZE(global_subrs),
1508fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org                          local_subrs, ARRAYSIZE(local_subrs)));
1509fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1510fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1511fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1512fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestStackOverflow) {
1513fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1514fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1515fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
1516fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
1517fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
1518fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
1519fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8,
1520fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1521fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1522fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_TRUE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1523fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1524fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1525fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1526fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
1527fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
1528fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
1529fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
1530fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      1, 2, 3, 4, 5, 6, 7, 8, 9,  // overflow
1531fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1532fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1533fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1534fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1535fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1536fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1537fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestDeprecatedOperators) {
1538fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1539fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1540fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, (12 << 8) + 0,  // dotsection operator, which is not supported.
1541fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1542fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1543fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1544fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1545fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1546fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1547fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, 16,  // 'blend'.
1548fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1549fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1550fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1551fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1552fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1553fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1554fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, (12 << 8) + 8,  // 'store'.
1555fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1556fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1557fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1558fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1559fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1560fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1561fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, (12 << 8) + 13,  // 'load'.
1562fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      kOpPrefix, ots::kEndChar,
1563fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1564fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1565fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1566fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1567fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org
1568fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.orgTEST(ValidateTest, TestUnterminatedCharString) {
1569fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  // No endchar operator.
1570fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1571fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1572fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      123,
1573fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1574fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1575fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1576fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1577fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1578fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      123, 456,
1579fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1580fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1581fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1582fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  {
1583fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    const int char_string[] = {
1584fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org      123, 456, kOpPrefix, ots::kReturn,
1585fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    };
1586fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org    EXPECT_FALSE(ValidateCharStrings(char_string, ARRAYSIZE(char_string)));
1587fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org  }
1588fbb12969b4421ce7a155b7b34a7d855580d0f669yusukes@chromium.org}
1589