1//===----------- Triple.cpp - Triple unit tests ---------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "gtest/gtest.h"
11#include "llvm/ADT/Triple.h"
12
13using namespace llvm;
14
15namespace {
16
17TEST(TripleTest, BasicParsing) {
18  Triple T;
19
20  T = Triple("");
21  EXPECT_EQ("", T.getArchName().str());
22  EXPECT_EQ("", T.getVendorName().str());
23  EXPECT_EQ("", T.getOSName().str());
24  EXPECT_EQ("", T.getEnvironmentName().str());
25
26  T = Triple("-");
27  EXPECT_EQ("", T.getArchName().str());
28  EXPECT_EQ("", T.getVendorName().str());
29  EXPECT_EQ("", T.getOSName().str());
30  EXPECT_EQ("", T.getEnvironmentName().str());
31
32  T = Triple("--");
33  EXPECT_EQ("", T.getArchName().str());
34  EXPECT_EQ("", T.getVendorName().str());
35  EXPECT_EQ("", T.getOSName().str());
36  EXPECT_EQ("", T.getEnvironmentName().str());
37
38  T = Triple("---");
39  EXPECT_EQ("", T.getArchName().str());
40  EXPECT_EQ("", T.getVendorName().str());
41  EXPECT_EQ("", T.getOSName().str());
42  EXPECT_EQ("", T.getEnvironmentName().str());
43
44  T = Triple("----");
45  EXPECT_EQ("", T.getArchName().str());
46  EXPECT_EQ("", T.getVendorName().str());
47  EXPECT_EQ("", T.getOSName().str());
48  EXPECT_EQ("-", T.getEnvironmentName().str());
49
50  T = Triple("a");
51  EXPECT_EQ("a", T.getArchName().str());
52  EXPECT_EQ("", T.getVendorName().str());
53  EXPECT_EQ("", T.getOSName().str());
54  EXPECT_EQ("", T.getEnvironmentName().str());
55
56  T = Triple("a-b");
57  EXPECT_EQ("a", T.getArchName().str());
58  EXPECT_EQ("b", T.getVendorName().str());
59  EXPECT_EQ("", T.getOSName().str());
60  EXPECT_EQ("", T.getEnvironmentName().str());
61
62  T = Triple("a-b-c");
63  EXPECT_EQ("a", T.getArchName().str());
64  EXPECT_EQ("b", T.getVendorName().str());
65  EXPECT_EQ("c", T.getOSName().str());
66  EXPECT_EQ("", T.getEnvironmentName().str());
67
68  T = Triple("a-b-c-d");
69  EXPECT_EQ("a", T.getArchName().str());
70  EXPECT_EQ("b", T.getVendorName().str());
71  EXPECT_EQ("c", T.getOSName().str());
72  EXPECT_EQ("d", T.getEnvironmentName().str());
73}
74
75TEST(TripleTest, ParsedIDs) {
76  Triple T;
77
78  T = Triple("i386-apple-darwin");
79  EXPECT_EQ(Triple::x86, T.getArch());
80  EXPECT_EQ(Triple::Apple, T.getVendor());
81  EXPECT_EQ(Triple::Darwin, T.getOS());
82  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
83
84  T = Triple("x86_64-pc-linux-gnu");
85  EXPECT_EQ(Triple::x86_64, T.getArch());
86  EXPECT_EQ(Triple::PC, T.getVendor());
87  EXPECT_EQ(Triple::Linux, T.getOS());
88  EXPECT_EQ(Triple::GNU, T.getEnvironment());
89
90  T = Triple("powerpc-bgp-linux");
91  EXPECT_EQ(Triple::ppc, T.getArch());
92  EXPECT_EQ(Triple::BGP, T.getVendor());
93  EXPECT_EQ(Triple::Linux, T.getOS());
94  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
95
96  T = Triple("powerpc-bgp-cnk");
97  EXPECT_EQ(Triple::ppc, T.getArch());
98  EXPECT_EQ(Triple::BGP, T.getVendor());
99  EXPECT_EQ(Triple::CNK, T.getOS());
100  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
101
102  T = Triple("powerpc64-bgq-linux");
103  EXPECT_EQ(Triple::ppc64, T.getArch());
104  EXPECT_EQ(Triple::BGQ, T.getVendor());
105  EXPECT_EQ(Triple::Linux, T.getOS());
106  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
107
108  T = Triple("powerpc-ibm-aix");
109  EXPECT_EQ(Triple::ppc, T.getArch());
110  EXPECT_EQ(Triple::IBM, T.getVendor());
111  EXPECT_EQ(Triple::AIX, T.getOS());
112  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
113
114  T = Triple("powerpc64-ibm-aix");
115  EXPECT_EQ(Triple::ppc64, T.getArch());
116  EXPECT_EQ(Triple::IBM, T.getVendor());
117  EXPECT_EQ(Triple::AIX, T.getOS());
118  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
119
120  T = Triple("powerpc-dunno-notsure");
121  EXPECT_EQ(Triple::ppc, T.getArch());
122  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
123  EXPECT_EQ(Triple::UnknownOS, T.getOS());
124  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
125
126  T = Triple("arm-none-none-eabi");
127  EXPECT_EQ(Triple::arm, T.getArch());
128  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
129  EXPECT_EQ(Triple::UnknownOS, T.getOS());
130  EXPECT_EQ(Triple::EABI, T.getEnvironment());
131
132  T = Triple("huh");
133  EXPECT_EQ(Triple::UnknownArch, T.getArch());
134}
135
136static std::string Join(StringRef A, StringRef B, StringRef C) {
137  std::string Str = A; Str += '-'; Str += B; Str += '-'; Str += C;
138  return Str;
139}
140
141static std::string Join(StringRef A, StringRef B, StringRef C, StringRef D) {
142  std::string Str = A; Str += '-'; Str += B; Str += '-'; Str += C; Str += '-';
143  Str += D; return Str;
144}
145
146TEST(TripleTest, Normalization) {
147
148  EXPECT_EQ("", Triple::normalize(""));
149  EXPECT_EQ("-", Triple::normalize("-"));
150  EXPECT_EQ("--", Triple::normalize("--"));
151  EXPECT_EQ("---", Triple::normalize("---"));
152  EXPECT_EQ("----", Triple::normalize("----"));
153
154  EXPECT_EQ("a", Triple::normalize("a"));
155  EXPECT_EQ("a-b", Triple::normalize("a-b"));
156  EXPECT_EQ("a-b-c", Triple::normalize("a-b-c"));
157  EXPECT_EQ("a-b-c-d", Triple::normalize("a-b-c-d"));
158
159  EXPECT_EQ("i386-b-c", Triple::normalize("i386-b-c"));
160  EXPECT_EQ("i386-a-c", Triple::normalize("a-i386-c"));
161  EXPECT_EQ("i386-a-b", Triple::normalize("a-b-i386"));
162  EXPECT_EQ("i386-a-b-c", Triple::normalize("a-b-c-i386"));
163
164  EXPECT_EQ("a-pc-c", Triple::normalize("a-pc-c"));
165  EXPECT_EQ("-pc-b-c", Triple::normalize("pc-b-c"));
166  EXPECT_EQ("a-pc-b", Triple::normalize("a-b-pc"));
167  EXPECT_EQ("a-pc-b-c", Triple::normalize("a-b-c-pc"));
168
169  EXPECT_EQ("a-b-linux", Triple::normalize("a-b-linux"));
170  EXPECT_EQ("--linux-b-c", Triple::normalize("linux-b-c"));
171  EXPECT_EQ("a--linux-c", Triple::normalize("a-linux-c"));
172
173  EXPECT_EQ("i386-pc-a", Triple::normalize("a-pc-i386"));
174  EXPECT_EQ("i386-pc-", Triple::normalize("-pc-i386"));
175  EXPECT_EQ("-pc-linux-c", Triple::normalize("linux-pc-c"));
176  EXPECT_EQ("-pc-linux", Triple::normalize("linux-pc-"));
177
178  EXPECT_EQ("i386", Triple::normalize("i386"));
179  EXPECT_EQ("-pc", Triple::normalize("pc"));
180  EXPECT_EQ("--linux", Triple::normalize("linux"));
181
182  EXPECT_EQ("x86_64--linux-gnu", Triple::normalize("x86_64-gnu-linux"));
183
184  // Check that normalizing a permutated set of valid components returns a
185  // triple with the unpermuted components.
186  StringRef C[4];
187  for (int Arch = 1+Triple::UnknownArch; Arch <= Triple::amdil; ++Arch) {
188    C[0] = Triple::getArchTypeName(Triple::ArchType(Arch));
189    for (int Vendor = 1+Triple::UnknownVendor; Vendor <= Triple::PC;
190         ++Vendor) {
191      C[1] = Triple::getVendorTypeName(Triple::VendorType(Vendor));
192      for (int OS = 1+Triple::UnknownOS; OS <= Triple::Minix; ++OS) {
193        C[2] = Triple::getOSTypeName(Triple::OSType(OS));
194
195        std::string E = Join(C[0], C[1], C[2]);
196        EXPECT_EQ(E, Triple::normalize(Join(C[0], C[1], C[2])));
197
198        EXPECT_EQ(E, Triple::normalize(Join(C[0], C[2], C[1])));
199        EXPECT_EQ(E, Triple::normalize(Join(C[1], C[2], C[0])));
200        EXPECT_EQ(E, Triple::normalize(Join(C[1], C[0], C[2])));
201        EXPECT_EQ(E, Triple::normalize(Join(C[2], C[0], C[1])));
202        EXPECT_EQ(E, Triple::normalize(Join(C[2], C[1], C[0])));
203
204        for (int Env = 1+Triple::UnknownEnvironment; Env <= Triple::MachO;
205             ++Env) {
206          C[3] = Triple::getEnvironmentTypeName(Triple::EnvironmentType(Env));
207
208          std::string F = Join(C[0], C[1], C[2], C[3]);
209          EXPECT_EQ(F, Triple::normalize(Join(C[0], C[1], C[2], C[3])));
210
211          EXPECT_EQ(F, Triple::normalize(Join(C[0], C[1], C[3], C[2])));
212          EXPECT_EQ(F, Triple::normalize(Join(C[0], C[2], C[3], C[1])));
213          EXPECT_EQ(F, Triple::normalize(Join(C[0], C[2], C[1], C[3])));
214          EXPECT_EQ(F, Triple::normalize(Join(C[0], C[3], C[1], C[2])));
215          EXPECT_EQ(F, Triple::normalize(Join(C[0], C[3], C[2], C[1])));
216          EXPECT_EQ(F, Triple::normalize(Join(C[1], C[2], C[3], C[0])));
217          EXPECT_EQ(F, Triple::normalize(Join(C[1], C[2], C[0], C[3])));
218          EXPECT_EQ(F, Triple::normalize(Join(C[1], C[3], C[0], C[2])));
219          EXPECT_EQ(F, Triple::normalize(Join(C[1], C[3], C[2], C[0])));
220          EXPECT_EQ(F, Triple::normalize(Join(C[1], C[0], C[2], C[3])));
221          EXPECT_EQ(F, Triple::normalize(Join(C[1], C[0], C[3], C[2])));
222          EXPECT_EQ(F, Triple::normalize(Join(C[2], C[3], C[0], C[1])));
223          EXPECT_EQ(F, Triple::normalize(Join(C[2], C[3], C[1], C[0])));
224          EXPECT_EQ(F, Triple::normalize(Join(C[2], C[0], C[1], C[3])));
225          EXPECT_EQ(F, Triple::normalize(Join(C[2], C[0], C[3], C[1])));
226          EXPECT_EQ(F, Triple::normalize(Join(C[2], C[1], C[3], C[0])));
227          EXPECT_EQ(F, Triple::normalize(Join(C[2], C[1], C[0], C[3])));
228          EXPECT_EQ(F, Triple::normalize(Join(C[3], C[0], C[1], C[2])));
229          EXPECT_EQ(F, Triple::normalize(Join(C[3], C[0], C[2], C[1])));
230          EXPECT_EQ(F, Triple::normalize(Join(C[3], C[1], C[2], C[0])));
231          EXPECT_EQ(F, Triple::normalize(Join(C[3], C[1], C[0], C[2])));
232          EXPECT_EQ(F, Triple::normalize(Join(C[3], C[2], C[0], C[1])));
233          EXPECT_EQ(F, Triple::normalize(Join(C[3], C[2], C[1], C[0])));
234        }
235      }
236    }
237  }
238
239  // Various real-world funky triples.  The value returned by GCC's config.sub
240  // is given in the comment.
241  EXPECT_EQ("i386--mingw32", Triple::normalize("i386-mingw32")); // i386-pc-mingw32
242  EXPECT_EQ("x86_64--linux-gnu", Triple::normalize("x86_64-linux-gnu")); // x86_64-pc-linux-gnu
243  EXPECT_EQ("i486--linux-gnu", Triple::normalize("i486-linux-gnu")); // i486-pc-linux-gnu
244  EXPECT_EQ("i386-redhat-linux", Triple::normalize("i386-redhat-linux")); // i386-redhat-linux-gnu
245  EXPECT_EQ("i686--linux", Triple::normalize("i686-linux")); // i686-pc-linux-gnu
246  EXPECT_EQ("arm-none--eabi", Triple::normalize("arm-none-eabi")); // arm-none-eabi
247}
248
249TEST(TripleTest, MutateName) {
250  Triple T;
251  EXPECT_EQ(Triple::UnknownArch, T.getArch());
252  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
253  EXPECT_EQ(Triple::UnknownOS, T.getOS());
254  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
255
256  T.setArchName("i386");
257  EXPECT_EQ(Triple::x86, T.getArch());
258  EXPECT_EQ("i386--", T.getTriple());
259
260  T.setVendorName("pc");
261  EXPECT_EQ(Triple::x86, T.getArch());
262  EXPECT_EQ(Triple::PC, T.getVendor());
263  EXPECT_EQ("i386-pc-", T.getTriple());
264
265  T.setOSName("linux");
266  EXPECT_EQ(Triple::x86, T.getArch());
267  EXPECT_EQ(Triple::PC, T.getVendor());
268  EXPECT_EQ(Triple::Linux, T.getOS());
269  EXPECT_EQ("i386-pc-linux", T.getTriple());
270
271  T.setEnvironmentName("gnu");
272  EXPECT_EQ(Triple::x86, T.getArch());
273  EXPECT_EQ(Triple::PC, T.getVendor());
274  EXPECT_EQ(Triple::Linux, T.getOS());
275  EXPECT_EQ("i386-pc-linux-gnu", T.getTriple());
276
277  T.setOSName("freebsd");
278  EXPECT_EQ(Triple::x86, T.getArch());
279  EXPECT_EQ(Triple::PC, T.getVendor());
280  EXPECT_EQ(Triple::FreeBSD, T.getOS());
281  EXPECT_EQ("i386-pc-freebsd-gnu", T.getTriple());
282
283  T.setOSAndEnvironmentName("darwin");
284  EXPECT_EQ(Triple::x86, T.getArch());
285  EXPECT_EQ(Triple::PC, T.getVendor());
286  EXPECT_EQ(Triple::Darwin, T.getOS());
287  EXPECT_EQ("i386-pc-darwin", T.getTriple());
288
289}
290
291TEST(TripleTest, BitWidthPredicates) {
292  Triple T;
293  EXPECT_FALSE(T.isArch16Bit());
294  EXPECT_FALSE(T.isArch32Bit());
295  EXPECT_FALSE(T.isArch64Bit());
296
297  T.setArch(Triple::arm);
298  EXPECT_FALSE(T.isArch16Bit());
299  EXPECT_TRUE(T.isArch32Bit());
300  EXPECT_FALSE(T.isArch64Bit());
301
302  T.setArch(Triple::hexagon);
303  EXPECT_FALSE(T.isArch16Bit());
304  EXPECT_TRUE(T.isArch32Bit());
305  EXPECT_FALSE(T.isArch64Bit());
306
307  T.setArch(Triple::mips);
308  EXPECT_FALSE(T.isArch16Bit());
309  EXPECT_TRUE(T.isArch32Bit());
310  EXPECT_FALSE(T.isArch64Bit());
311
312  T.setArch(Triple::mips64);
313  EXPECT_FALSE(T.isArch16Bit());
314  EXPECT_FALSE(T.isArch32Bit());
315  EXPECT_TRUE(T.isArch64Bit());
316
317  T.setArch(Triple::msp430);
318  EXPECT_TRUE(T.isArch16Bit());
319  EXPECT_FALSE(T.isArch32Bit());
320  EXPECT_FALSE(T.isArch64Bit());
321
322  T.setArch(Triple::ppc);
323  EXPECT_FALSE(T.isArch16Bit());
324  EXPECT_TRUE(T.isArch32Bit());
325  EXPECT_FALSE(T.isArch64Bit());
326
327  T.setArch(Triple::ppc64);
328  EXPECT_FALSE(T.isArch16Bit());
329  EXPECT_FALSE(T.isArch32Bit());
330  EXPECT_TRUE(T.isArch64Bit());
331
332  T.setArch(Triple::x86);
333  EXPECT_FALSE(T.isArch16Bit());
334  EXPECT_TRUE(T.isArch32Bit());
335  EXPECT_FALSE(T.isArch64Bit());
336
337  T.setArch(Triple::x86_64);
338  EXPECT_FALSE(T.isArch16Bit());
339  EXPECT_FALSE(T.isArch32Bit());
340  EXPECT_TRUE(T.isArch64Bit());
341}
342
343TEST(TripleTest, BitWidthArchVariants) {
344  Triple T;
345  EXPECT_EQ(Triple::UnknownArch, T.get32BitArchVariant().getArch());
346  EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
347
348  T.setArch(Triple::UnknownArch);
349  EXPECT_EQ(Triple::UnknownArch, T.get32BitArchVariant().getArch());
350  EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
351
352  T.setArch(Triple::arm);
353  EXPECT_EQ(Triple::arm, T.get32BitArchVariant().getArch());
354  EXPECT_EQ(Triple::UnknownArch, T.get64BitArchVariant().getArch());
355
356  T.setArch(Triple::mips);
357  EXPECT_EQ(Triple::mips, T.get32BitArchVariant().getArch());
358  EXPECT_EQ(Triple::mips64, T.get64BitArchVariant().getArch());
359
360  T.setArch(Triple::mipsel);
361  EXPECT_EQ(Triple::mipsel, T.get32BitArchVariant().getArch());
362  EXPECT_EQ(Triple::mips64el, T.get64BitArchVariant().getArch());
363
364  T.setArch(Triple::ppc);
365  EXPECT_EQ(Triple::ppc, T.get32BitArchVariant().getArch());
366  EXPECT_EQ(Triple::ppc64, T.get64BitArchVariant().getArch());
367
368  T.setArch(Triple::nvptx);
369  EXPECT_EQ(Triple::nvptx, T.get32BitArchVariant().getArch());
370  EXPECT_EQ(Triple::nvptx64, T.get64BitArchVariant().getArch());
371
372  T.setArch(Triple::sparc);
373  EXPECT_EQ(Triple::sparc, T.get32BitArchVariant().getArch());
374  EXPECT_EQ(Triple::sparcv9, T.get64BitArchVariant().getArch());
375
376  T.setArch(Triple::x86);
377  EXPECT_EQ(Triple::x86, T.get32BitArchVariant().getArch());
378  EXPECT_EQ(Triple::x86_64, T.get64BitArchVariant().getArch());
379
380  T.setArch(Triple::mips64);
381  EXPECT_EQ(Triple::mips, T.get32BitArchVariant().getArch());
382  EXPECT_EQ(Triple::mips64, T.get64BitArchVariant().getArch());
383
384  T.setArch(Triple::mips64el);
385  EXPECT_EQ(Triple::mipsel, T.get32BitArchVariant().getArch());
386  EXPECT_EQ(Triple::mips64el, T.get64BitArchVariant().getArch());
387
388  T.setArch(Triple::ppc64);
389  EXPECT_EQ(Triple::ppc, T.get32BitArchVariant().getArch());
390  EXPECT_EQ(Triple::ppc64, T.get64BitArchVariant().getArch());
391
392  T.setArch(Triple::nvptx64);
393  EXPECT_EQ(Triple::nvptx, T.get32BitArchVariant().getArch());
394  EXPECT_EQ(Triple::nvptx64, T.get64BitArchVariant().getArch());
395
396  T.setArch(Triple::sparcv9);
397  EXPECT_EQ(Triple::sparc, T.get32BitArchVariant().getArch());
398  EXPECT_EQ(Triple::sparcv9, T.get64BitArchVariant().getArch());
399
400  T.setArch(Triple::x86_64);
401  EXPECT_EQ(Triple::x86, T.get32BitArchVariant().getArch());
402  EXPECT_EQ(Triple::x86_64, T.get64BitArchVariant().getArch());
403}
404
405TEST(TripleTest, getOSVersion) {
406  Triple T;
407  unsigned Major, Minor, Micro;
408
409  T = Triple("i386-apple-darwin9");
410  EXPECT_TRUE(T.isMacOSX());
411  EXPECT_FALSE(T.isiOS());
412  EXPECT_FALSE(T.isArch16Bit());
413  EXPECT_TRUE(T.isArch32Bit());
414  EXPECT_FALSE(T.isArch64Bit());
415  T.getMacOSXVersion(Major, Minor, Micro);
416  EXPECT_EQ((unsigned)10, Major);
417  EXPECT_EQ((unsigned)5, Minor);
418  EXPECT_EQ((unsigned)0, Micro);
419  T.getiOSVersion(Major, Minor, Micro);
420  EXPECT_EQ((unsigned)3, Major);
421  EXPECT_EQ((unsigned)0, Minor);
422  EXPECT_EQ((unsigned)0, Micro);
423
424  T = Triple("x86_64-apple-darwin9");
425  EXPECT_TRUE(T.isMacOSX());
426  EXPECT_FALSE(T.isiOS());
427  EXPECT_FALSE(T.isArch16Bit());
428  EXPECT_FALSE(T.isArch32Bit());
429  EXPECT_TRUE(T.isArch64Bit());
430  T.getMacOSXVersion(Major, Minor, Micro);
431  EXPECT_EQ((unsigned)10, Major);
432  EXPECT_EQ((unsigned)5, Minor);
433  EXPECT_EQ((unsigned)0, Micro);
434  T.getiOSVersion(Major, Minor, Micro);
435  EXPECT_EQ((unsigned)3, Major);
436  EXPECT_EQ((unsigned)0, Minor);
437  EXPECT_EQ((unsigned)0, Micro);
438
439  T = Triple("x86_64-apple-macosx");
440  EXPECT_TRUE(T.isMacOSX());
441  EXPECT_FALSE(T.isiOS());
442  EXPECT_FALSE(T.isArch16Bit());
443  EXPECT_FALSE(T.isArch32Bit());
444  EXPECT_TRUE(T.isArch64Bit());
445  T.getMacOSXVersion(Major, Minor, Micro);
446  EXPECT_EQ((unsigned)10, Major);
447  EXPECT_EQ((unsigned)4, Minor);
448  EXPECT_EQ((unsigned)0, Micro);
449  T.getiOSVersion(Major, Minor, Micro);
450  EXPECT_EQ((unsigned)3, Major);
451  EXPECT_EQ((unsigned)0, Minor);
452  EXPECT_EQ((unsigned)0, Micro);
453
454  T = Triple("x86_64-apple-macosx10.7");
455  EXPECT_TRUE(T.isMacOSX());
456  EXPECT_FALSE(T.isiOS());
457  EXPECT_FALSE(T.isArch16Bit());
458  EXPECT_FALSE(T.isArch32Bit());
459  EXPECT_TRUE(T.isArch64Bit());
460  T.getMacOSXVersion(Major, Minor, Micro);
461  EXPECT_EQ((unsigned)10, Major);
462  EXPECT_EQ((unsigned)7, Minor);
463  EXPECT_EQ((unsigned)0, Micro);
464  T.getiOSVersion(Major, Minor, Micro);
465  EXPECT_EQ((unsigned)3, Major);
466  EXPECT_EQ((unsigned)0, Minor);
467  EXPECT_EQ((unsigned)0, Micro);
468
469  T = Triple("armv7-apple-ios");
470  EXPECT_FALSE(T.isMacOSX());
471  EXPECT_TRUE(T.isiOS());
472  EXPECT_FALSE(T.isArch16Bit());
473  EXPECT_TRUE(T.isArch32Bit());
474  EXPECT_FALSE(T.isArch64Bit());
475  T.getMacOSXVersion(Major, Minor, Micro);
476  EXPECT_EQ((unsigned)10, Major);
477  EXPECT_EQ((unsigned)4, Minor);
478  EXPECT_EQ((unsigned)0, Micro);
479  T.getiOSVersion(Major, Minor, Micro);
480  EXPECT_EQ((unsigned)3, Major);
481  EXPECT_EQ((unsigned)0, Minor);
482  EXPECT_EQ((unsigned)0, Micro);
483
484  T = Triple("armv7-apple-ios5.0");
485  EXPECT_FALSE(T.isMacOSX());
486  EXPECT_TRUE(T.isiOS());
487  EXPECT_FALSE(T.isArch16Bit());
488  EXPECT_TRUE(T.isArch32Bit());
489  EXPECT_FALSE(T.isArch64Bit());
490  T.getMacOSXVersion(Major, Minor, Micro);
491  EXPECT_EQ((unsigned)10, Major);
492  EXPECT_EQ((unsigned)4, Minor);
493  EXPECT_EQ((unsigned)0, Micro);
494  T.getiOSVersion(Major, Minor, Micro);
495  EXPECT_EQ((unsigned)5, Major);
496  EXPECT_EQ((unsigned)0, Minor);
497  EXPECT_EQ((unsigned)0, Micro);
498}
499
500}
501