TEST(VersionTest, GetComponents_UnBreakable) { ApplicationVersion version (L"123"); vector <int> components; components = version.GetComponents(); EXPECT_THAT(components.size(), 1); EXPECT_THAT(components[0], 123); }
TEST(VersionTest, GetComponents_Two) { ApplicationVersion version (L"1.2"); vector <int> components; components = version.GetComponents(); EXPECT_THAT(components.size(), 2); EXPECT_THAT(components[0], 1); EXPECT_THAT(components[1], 2); }
bool ApplicationVersion::operator== (ApplicationVersion other) { if (GetComponents().size() != other.GetComponents().size()) return false; for (unsigned int i = 0; i < GetComponents().size(); i++) { if (GetComponents().at(i) != other.GetComponents().at(i)) return false; } return true; }
bool ApplicationVersion::operator > (ApplicationVersion other) { if (GetComponents().size() != other.GetComponents().size()) { return _majorDiferentSizes(other); } for (unsigned int i = 0; i < GetComponents().size(); i++) { if (GetComponents().at(i) == other.GetComponents().at(i)) continue; return GetComponents().at(i) > other.GetComponents().at(i); } return false; }
// If version A is 10.0.2 and B 10.2 compare starting by the left only the MIN of both // If both the MIN number of the digits are equal, return as major the one with more digits bool ApplicationVersion::_majorDiferentSizes (ApplicationVersion other) { unsigned int size; size = GetComponents().size() < other.GetComponents().size() ? GetComponents().size() : other.GetComponents().size(); for (unsigned int i = 0; i < size; i++) { if (GetComponents().at(i) == other.GetComponents().at(i)) continue; return GetComponents().at(i) > other.GetComponents().at(i); } return GetComponents().size() > other.GetComponents().size(); }
void ApplicationVersionRepository::add(const ApplicationVersion &entity, bool *ok) { if (!isValid() || !entity.isValid() || entity.isCreatedByRepo()) return bSet(ok, false); QVariantMap values; values.insert("client_type", int(entity.clienType())); values.insert("os_type", int(entity.os())); values.insert("portable", int(entity.portable())); values.insert("processor_architecture_type", int(entity.processorArchitecture())); values.insert("download_url", entity.downloadUrl().toString()); values.insert("version", entity.version().toString()); bSet(ok, Source->insert("application_versions", values).success()); }
void ApplicationVersionRepository::edit(const ApplicationVersion &entity, bool *ok) { if (!isValid() || !entity.isValid() || entity.isCreatedByRepo()) return bSet(ok, false); QVariantMap values; values.insert("download_url", entity.downloadUrl().toString()); values.insert("version", entity.version().toString()); QString ws = "client_type = :client_type AND os_type = :os_type AND portable = :portable " "AND processor_architecture_type = :processor_architecture_type"; QVariantMap wvalues; wvalues.insert(":client_type", int(entity.clienType())); wvalues.insert(":os_type", int(entity.os())); wvalues.insert(":portable", int(entity.portable())); wvalues.insert(":processor_architecture_type", int(entity.processorArchitecture())); bSet(ok, Source->update("application_versions", values, BSqlWhere(ws, wvalues)).success()); }
TEST(VersionTest, GetMajorVersion_None) { ApplicationVersion version; EXPECT_THAT(version.GetMajorVersion(), 0); }
TEST(VersionTest, GetMajorVersion_TwoDigits) { ApplicationVersion version (L"3.2"); EXPECT_THAT(version.GetMajorVersion(), 3); }