summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/qfileinfo/qfileinfo.qs36
-rw-r--r--tests/qfileinfo/test.cpp5
-rw-r--r--tests/test.js14
3 files changed, 55 insertions, 0 deletions
diff --git a/tests/qfileinfo/qfileinfo.qs b/tests/qfileinfo/qfileinfo.qs
new file mode 100644
index 0000000..e061d2c
--- /dev/null
+++ b/tests/qfileinfo/qfileinfo.qs
@@ -0,0 +1,36 @@
+include("../test.js")
+
+var absolute = new QFileInfo(utils.currentScripRoot + "/test.cpp")
+var relative = new QFileInfo("relative")
+
+compare(absolute.exists, true)
+compare(relative.exists, false)
+
+compare(relative.filePath, "relative")
+assert(endsWith(absolute.filePath, "test.cpp"), "filePath for absolute files")
+
+assert(startsWith(relative.absoluteFilePath,"/"))
+compare(absolute.fileName, "test.cpp")
+
+compare(absolute.isRelative, false)
+compare(relative.isRelative, true)
+compare(absolute.size, 61)
+
+assert(absolute.created.getFullYear() > 2012)
+
+var gotIt = false
+try {
+ new QFileInfo()
+}
+catch(message) {
+ gotIt = true
+}
+assert(gotIt, "We should throw an error when constructing a QFileInfo without a file")
+
+function endsWith(str,pattern) {
+ return str.substr(str.length-pattern.length,pattern.length) == pattern
+}
+
+function startsWith(str,pattern) {
+ return str.substr(0,pattern.length) == pattern
+}
diff --git a/tests/qfileinfo/test.cpp b/tests/qfileinfo/test.cpp
new file mode 100644
index 0000000..4304ec5
--- /dev/null
+++ b/tests/qfileinfo/test.cpp
@@ -0,0 +1,5 @@
+class Foo {
+ void bar() {
+ qDebug("yay");
+ }
+};
diff --git a/tests/test.js b/tests/test.js
index 4bb7f60..9269328 100644
--- a/tests/test.js
+++ b/tests/test.js
@@ -72,4 +72,18 @@ if (TEST_JS_LOADED == undefined) {
compare(editor.currentColumn(), column, message)
}
+ function assert(cond, message) {
+ if ( verbose ) {
+ if ( message != undefined )
+ console.log("assert(" + message + "): " + cond)
+ else
+ console.log("assert: " + cond)
+ }
+ if ( !cond ) {
+ if ( message != undefined )
+ error("Assertion failed: " + message)
+ else
+ error("Assertion failed")
+ }
+ }
}