From 83f360b98d28e3a34dcabce170e1e4d9577e50d3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Sat, 9 Apr 2011 17:41:35 +0200
Subject: Fixed tests on windows.


diff --git a/Swiften/Base/ByteArray.h b/Swiften/Base/ByteArray.h
index 9e7a928..d55da1f 100644
--- a/Swiften/Base/ByteArray.h
+++ b/Swiften/Base/ByteArray.h
@@ -139,6 +139,14 @@ namespace Swift {
 			static std::vector<unsigned char> create(const unsigned char* c, size_t n);
 			static std::vector<unsigned char> create(const char* c, size_t n);
 
+			static const unsigned char* data(const std::vector<unsigned char>& v) {
+				return v.empty() ? NULL : &v[0];
+			}
+
+			static const char* charData(const std::vector<unsigned char>& v) {
+				return v.empty() ? NULL : reinterpret_cast<const char*>(&v[0]);
+			}
+
 		private:
 			std::vector<unsigned char> data_;
 	};
diff --git a/Swiften/FileTransfer/UnitTest/IBBReceiveSessionTest.cpp b/Swiften/FileTransfer/UnitTest/IBBReceiveSessionTest.cpp
index 88d9cd4..590443f 100644
--- a/Swiften/FileTransfer/UnitTest/IBBReceiveSessionTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/IBBReceiveSessionTest.cpp
@@ -34,6 +34,7 @@ class IBBReceiveSessionTest : public CppUnit::TestFixture {
 		void setUp() {
 			stanzaChannel = new DummyStanzaChannel();
 			iqRouter = new IQRouter(stanzaChannel);
+			finished = false;
 		}
 
 		void tearDown() {
diff --git a/Swiften/StringCodecs/SHA1.cpp b/Swiften/StringCodecs/SHA1.cpp
index a78a7b0..2703796 100644
--- a/Swiften/StringCodecs/SHA1.cpp
+++ b/Swiften/StringCodecs/SHA1.cpp
@@ -185,7 +185,7 @@ SHA1::SHA1() {
 
 SHA1& SHA1::update(const std::vector<unsigned char>& input) {
 	std::vector<unsigned char> inputCopy(input);
-	Update(&context, (boost::uint8_t*) &inputCopy[0], inputCopy.size());
+	Update(&context, (boost::uint8_t*) ByteArray::data(inputCopy), inputCopy.size());
 	return *this;
 }
 
@@ -193,7 +193,7 @@ std::vector<unsigned char> SHA1::getHash() const {
 	std::vector<unsigned char> digest;
 	digest.resize(20);
 	CTX contextCopy(context);
-	Final((boost::uint8_t*) &digest[0], &contextCopy);
+	Final((boost::uint8_t*) ByteArray::data(digest), &contextCopy);
 	return digest;
 }
 
@@ -202,7 +202,7 @@ ByteArray SHA1::getHash(const ByteArray& input) {
 	Init(&context);
 
 	std::vector<unsigned char> inputCopy(input.getVector());
-	Update(&context, (boost::uint8_t*) &inputCopy[0], inputCopy.size());
+	Update(&context, (boost::uint8_t*) ByteArray::data(inputCopy), inputCopy.size());
 
 	ByteArray digest;
 	digest.resize(20);
-- 
cgit v0.10.2-6-g49f6