File: test_ncFile_Flags.cpp

package info (click to toggle)
netcdf-cxx 4.3.1-5
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 3,456 kB
  • sloc: cpp: 8,506; sh: 4,548; ansic: 4,251; xml: 173; makefile: 145
file content (68 lines) | stat: -rw-r--r-- 1,434 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*! Test that C++ library can access NC_SHARE, other flags.
  Copyright Unidata 2018

  Basic test to start, will be fleshed out later.

  @author wfisher
*/
#include <iostream>
#include <string>
#include <netcdf>
#include "test_utilities.h"

using namespace std;
using namespace netCDF;
using namespace netCDF::exceptions;

/*! Standard 'main' function'.
 *
 */
int main() {


  NcFile file;

  /* Test opening a new file. */
  cout << "Creating file...";
  try {
    file.create("test_ncFile_Flags_newFile.nc",NC_NETCDF4);
    cout << "Success." << endl;
  } catch (NcException &e) {
    cout << "Caught unexpected exception." << endl;
    return e.errorCode();
  }

  /* Test closing the file. */
  cout << "Closing file...";
  try {
    file.close();
    cout << "Success." << endl;
  } catch (NcException &e) {
    cout << "Caught unexpected exception." << endl;
    return e.errorCode();
  }

  cout << "Opening file...";
  try {
    file.open("test_ncFile_Flags_newFile.nc",NC_SHARE | NC_NOWRITE);
    cout << "Success." << endl;
  } catch (NcException &e) {
    cout << "Caught unexpected exception." << endl;
    return e.errorCode();
  }

  /* Test closing the file. */
  cout << "Closing file...";
  try {
    file.close();
    cout << "Success." << endl;
  } catch (NcException &e) {
    cout << "Caught unexpected exception." << endl;
    return e.errorCode();
  }


  cout << endl << "Finished." << endl;
  return 0;

}