TEST(ByteArrayTest, Left) { ByteArray ba = "This is a test"; ByteArray result1 = ba.left(4); ASSERT_STRCASEEQ(ba, "This is a test"); ASSERT_STRCASEEQ(result1, "This"); ByteArray clone = ba; ByteArray result2 = ba.left(4); ASSERT_STRCASEEQ(ba, "This is a test"); ASSERT_STRCASEEQ(clone, "This is a test"); ASSERT_STRCASEEQ(result2, "This"); ByteArray result3 = ba.left(0); ASSERT_STRCASEEQ(result3, ""); ByteArray result4 = ba.left(100); ASSERT_STRCASEEQ(result4, "This is a test"); }
static inline GccArguments::Lang guessLang(const Path &fullPath) { ByteArray compiler = fullPath.fileName(); ByteArray c; int dash = compiler.lastIndexOf('-'); if (dash >= 0) { c = ByteArray(compiler.constData() + dash + 1, compiler.size() - dash - 1); } else { c = ByteArray(compiler.constData(), compiler.size()); } if (c.size() != compiler.size()) { bool isVersion = true; for (int i=0; i<c.size(); ++i) { if ((c.at(i) < '0' || c.at(i) > '9') && c.at(i) != '.') { isVersion = false; break; } } if (isVersion) { dash = compiler.lastIndexOf('-', dash - 1); if (dash >= 0) { c = compiler.mid(dash + 1, compiler.size() - c.size() - 2 - dash); } else { c = compiler.left(dash); } } } GccArguments::Lang lang = GccArguments::NoLang; if (c.startsWith("g++") || c.startsWith("c++")) { lang = GccArguments::CPlusPlus; } else if (c.startsWith("gcc") || c.startsWith("cc")) { lang = GccArguments::C; } return lang; }