[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [Amarok]  Suppress compiler warnings associated to casting
From:       Erik Hovland <erik () hovland ! org>
Date:       2009-08-20 16:03:03
Message-ID: 200908201603.n7KG33XL017181 () Wurst ! kollide ! net
[Download RAW message or body]

commit 3267fdcdaa209256a909d77eb396eb8ca1e25c29
Author:     Erik Hovland <erik@hovland.org>
AuthorDate: Thu Aug 20 08:50:05 2009 -0700
Commit:     Erik Hovland <erik@hovland.org>
CommitDate: Thu Aug 20 08:59:36 2009 -0700

    Suppress compiler warnings associated to casting
    
    The test code does a lot of casting. Likely because the Qt compare
    macros require the correct types. But the casting is unnecessary
    when dealing w/ constants. C/C++ already has keywords to make sure
    the constants are the right type (in this case U/u and F/f).
    
    To belabor the point further, since this is C++ code using C like
    casting '(type)variable' is probably not a good idea. Instead use
    C++ like casting, 'type(variable)' or 'static_cast<type>(variable)'.

diff --git a/tests/meta/TestMetaTrack.cpp b/tests/meta/TestMetaTrack.cpp
index fa01d6a..7903dfb 100644
--- a/tests/meta/TestMetaTrack.cpp
+++ b/tests/meta/TestMetaTrack.cpp
@@ -161,12 +161,12 @@ void TestMetaTrack::testDiscNumber()
 
 void TestMetaTrack::testLastPlayed()
 {
-    QCOMPARE( m_testTrack1->lastPlayed(), (uint)4294967295 ); // portability?
+    QCOMPARE( m_testTrack1->lastPlayed(), 4294967295U ); // portability?
 }
 
 void TestMetaTrack::testFirstPlayed()
 {
-    QCOMPARE( m_testTrack1->firstPlayed(), (uint)4294967295 ); // portability?
+    QCOMPARE( m_testTrack1->firstPlayed(), 4294967295U ); // portability?
 }
 
 void TestMetaTrack::testPlayCount()
diff --git a/tests/meta/file/TestMetaFileTrack.cpp b/tests/meta/file/TestMetaFileTrack.cpp
index 914d920..be08224 100644
--- a/tests/meta/file/TestMetaFileTrack.cpp
+++ b/tests/meta/file/TestMetaFileTrack.cpp
@@ -357,36 +357,36 @@ void TestMetaFileTrack::testBitrate()
 
 void TestMetaFileTrack::testSetGetLastPlayed()
 {
-    QCOMPARE( track->lastPlayed(), (uint)4294967295 ); // portability?
+    QCOMPARE( track->lastPlayed(), 4294967295U ); // portability?
 
     track->setLastPlayed( 0 );
-    QCOMPARE( track->lastPlayed(), (uint)0 );
+    QCOMPARE( track->lastPlayed(), 0U );
 
     track->setLastPlayed( 1 );
-    QCOMPARE( track->lastPlayed(), (uint)1 );
+    QCOMPARE( track->lastPlayed(), 1U );
 
     track->setLastPlayed( 23 );
-    QCOMPARE( track->lastPlayed(), (uint)23 );
+    QCOMPARE( track->lastPlayed(), 23U );
 
-    track->setLastPlayed( 4294967295 );
-    QCOMPARE( track->lastPlayed(), (uint)4294967295 );
+    track->setLastPlayed( 4294967295U );
+    QCOMPARE( track->lastPlayed(), 4294967295U );
 }
 
 void TestMetaFileTrack::testSetGetFirstPlayed()
 {
-    QCOMPARE( track->firstPlayed(), (uint)4294967295 );
+    QCOMPARE( track->firstPlayed(), 4294967295U );
 
     track->setFirstPlayed( 0 );
-    QCOMPARE( track->firstPlayed(), (uint)0 );
+    QCOMPARE( track->firstPlayed(), 0U );
 
     track->setFirstPlayed( 1 );
-    QCOMPARE( track->firstPlayed(), (uint)1 );
+    QCOMPARE( track->firstPlayed(), 1U );
 
     track->setFirstPlayed( 23 );
-    QCOMPARE( track->firstPlayed(), (uint)23 );
+    QCOMPARE( track->firstPlayed(), 23U );
 
-    track->setFirstPlayed( 4294967295 );
-    QCOMPARE( track->firstPlayed(), (uint)4294967295 );
+    track->setFirstPlayed( 4294967295U );
+    QCOMPARE( track->firstPlayed(), 4294967295U );
 }
 
 void TestMetaFileTrack::testSetGetPlayCount()
@@ -409,14 +409,14 @@ void TestMetaFileTrack::testSetGetPlayCount()
 void TestMetaFileTrack::testReplayGain()
 {
     // HACK: double fails even with fuzzy compare :(
-    QCOMPARE( (float)track->replayGain( Meta::Track::TrackReplayGain ), (float)-6.655 );
-    QCOMPARE( (float)track->replayGain( Meta::Track::AlbumReplayGain ), (float)-6.655 );
+    QCOMPARE( static_cast<float>( track->replayGain( Meta::Track::TrackReplayGain ) ), -6.655f );
+    QCOMPARE( static_cast<float>( track->replayGain( Meta::Track::AlbumReplayGain ) ), -6.655f );
 }
 
 void TestMetaFileTrack::testReplayPeakGain()
 {
-    QCOMPARE( (float)track->replayPeakGain( Meta::Track::TrackReplayGain ), (float)4.1263 );
-    QCOMPARE( (float)track->replayPeakGain( Meta::Track::AlbumReplayGain ), (float)4.1263 );
+    QCOMPARE( static_cast<float>( track->replayPeakGain( Meta::Track::TrackReplayGain ) ), 4.1263f );
+    QCOMPARE( (float)track->replayPeakGain( Meta::Track::AlbumReplayGain ), 4.1263f );
 }
 
 void TestMetaFileTrack::testType()


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic