From 4a612269263ff6eb770e6568f3eb41e89ab76de9 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 25 Mar 2021 13:36:06 +0100 Subject: [PATCH] #7494 Summary Plot: Lumped completions short names are wrong Replace tabs in summary quantity name with space --- .../FileInterface/RifReaderEclipseSummary.cpp | 2 ++ .../UnitTests/RiaStdStringTools-Test.cpp | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/ApplicationLibCode/FileInterface/RifReaderEclipseSummary.cpp b/ApplicationLibCode/FileInterface/RifReaderEclipseSummary.cpp index 4a0b797af8..dcd2241e68 100644 --- a/ApplicationLibCode/FileInterface/RifReaderEclipseSummary.cpp +++ b/ApplicationLibCode/FileInterface/RifReaderEclipseSummary.cpp @@ -289,6 +289,8 @@ std::string stringFromPointer( const char* pointerToChar ) if ( pointerToChar ) { myString = pointerToChar; + + replace( myString.begin(), myString.end(), '\t', ' ' ); } return myString; diff --git a/ApplicationLibCode/UnitTests/RiaStdStringTools-Test.cpp b/ApplicationLibCode/UnitTests/RiaStdStringTools-Test.cpp index 4c778765c5..07732214de 100644 --- a/ApplicationLibCode/UnitTests/RiaStdStringTools-Test.cpp +++ b/ApplicationLibCode/UnitTests/RiaStdStringTools-Test.cpp @@ -41,3 +41,19 @@ TEST( RiaStdStringToolsTest, EditDistance ) EXPECT_EQ( 3, RiaStdStringTools::computeEditDistance( "Saturday", "Sunday" ) ); EXPECT_EQ( 3, RiaStdStringTools::computeEditDistance( "Sunday", "Saturday" ) ); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST( RiaStdStringToolsTest, TrimStrings ) +{ + // Test replace of tabs with space + { + std::string text = "test\t\tnext word"; + + replace( text.begin(), text.end(), '\t', ' ' ); + + std::string expectedText = "test next word"; + EXPECT_EQ( text, expectedText ); + } +}