Permalink
Browse files

addons: add AddonVersion::Test() to document irregularities

  • Loading branch information...
Montellese committed Mar 25, 2012
1 parent 0908155 commit f6ec198de2f4f15d14a3f05f70383071ad43b208
Showing with 30 additions and 0 deletions.
  1. +28 −0 xbmc/addons/AddonVersion.cpp
  2. +2 −0 xbmc/addons/AddonVersion.h
@@ -136,4 +136,32 @@ namespace ADDON
return true;
}
+
+ bool AddonVersion::Test()
+ {
+ AddonVersion v1_0("1.0");
+ AddonVersion v1_00("1.00");
+ AddonVersion v1_0_0("1.0.0");
+ AddonVersion v1_1("1.1");
+ AddonVersion v1_01("1.01");
+ AddonVersion v1_0_1("1.0.1");
+
+ bool ret = false;
+
+ // These are totally sane
+ ret = (v1_0 < v1_1) && (v1_0 < v1_01) && (v1_0 < v1_0_1) &&
+ (v1_1 > v1_0_1) && (v1_01 > v1_0_1);
+
+ // These are rather sane
+ ret &= (v1_0 != v1_0_0) && (v1_0 < v1_0_0) && (v1_0_0 > v1_0) &&
+ (v1_00 != v1_0_0) && (v1_00 < v1_0_0) && (v1_0_0 > v1_00);
+
+ // These aren't totally sane
+ // BEWARE: neither (v1_0 == v1_00) nor (v1_0 < v1_00) nor (v1_0 > v1_00) are true
+ ret &= (v1_0 != v1_00) && !(v1_0 < v1_00) && !(v1_0 > v1_00);
+ // BEWARE: neither (v1_1 == v1_01) nor (v1_1 < v1_01) nor (v1_1 > v1_01) are true
+ ret &= (v1_1 != v1_01) && !(v1_1 < v1_01) && !(v1_1 > v1_01);
+
+ return ret;
+ }
}
@@ -45,6 +45,8 @@ namespace ADDON
static bool SplitFileName(CStdString& ID, CStdString& version,
const CStdString& filename);
+
+ static bool Test();
protected:
CStdString m_originalVersion;
int mEpoch;

0 comments on commit f6ec198

Please sign in to comment.