stdcpp/tsrc/Boost_test/array/src/array4.cpp
changeset 31 ce057bb09d0b
parent 0 e4d67989cc36
equal deleted inserted replaced
30:e20de85af2ee 31:ce057bb09d0b
       
     1 /* example for using class array<>
       
     2  * (C) Copyright Nicolai M. Josuttis 2001.
       
     3  * Distributed under the Boost Software License, Version 1.0. (See
       
     4  * accompanying file LICENSE_1_0.txt or copy at
       
     5  * http://www.boost.org/LICENSE_1_0.txt)
       
     6  */
       
     7 /*
       
     8  * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
       
     9 */
       
    10 
       
    11 #include <algorithm>
       
    12 #include <functional>
       
    13 #include <string>
       
    14 #include <iostream>
       
    15 #include <boost/array.hpp>
       
    16 
       
    17 #ifdef __SYMBIAN32__
       
    18 #include "std_log_result.h"
       
    19 #define LOG_FILENAME_LINE __FILE__, __LINE__
       
    20 #endif
       
    21 int main()
       
    22 {
       
    23 std_log(LOG_FILENAME_LINE,"[Test Case for array4]");
       
    24     // array of arrays of seasons
       
    25     boost::array<boost::array<std::string,4>,2> seasons_i18n = {
       
    26         { { { "spring", "summer", "autumn", "winter", } },
       
    27           { { "Fruehling", "Sommer", "Herbst", "Winter" } }
       
    28         }
       
    29     };
       
    30 
       
    31     // for any array of seasons print seasons
       
    32     for (unsigned i=0; i<seasons_i18n.size(); ++i) {
       
    33         boost::array<std::string,4> seasons = seasons_i18n[i];
       
    34         for (unsigned j=0; j<seasons.size(); ++j) {
       
    35             std::cout << seasons[j] << " ";
       
    36         }
       
    37         std::cout << std::endl;
       
    38     }
       
    39 
       
    40     // print first element of first array
       
    41     std::cout << "first element of first array: "
       
    42               << seasons_i18n[0][0] << std::endl;
       
    43 
       
    44     // print last element of last array
       
    45     std::cout << "last element of last array: "
       
    46               << seasons_i18n[seasons_i18n.size()-1][seasons_i18n[0].size()-1]
       
    47               << std::endl;
       
    48    if(seasons_i18n[0][0]!= "spring"  && seasons_i18n[seasons_i18n.size()-1][seasons_i18n[0].size()-1] != "Winter")
       
    49    {
       
    50    std_log(LOG_FILENAME_LINE,"Result : Failed"); 
       
    51 		assert_failed = true; 
       
    52    }
       
    53    else
       
    54    std_log(LOG_FILENAME_LINE,"Result : Passed"); 
       
    55 #ifdef __SYMBIAN32__
       
    56 	testResultXml("array4");
       
    57 	close_log_file();
       
    58 #endif
       
    59 
       
    60     return 0;  // makes Visual-C++ compiler happy
       
    61 }
       
    62