LCOV - code coverage report
Current view: top level - src/interfaces/ecpg/test/connect - test1.pgc (source / functions) Hit Total Coverage
Test: PostgreSQL 13devel Lines: 26 26 100.0 %
Date: 2019-11-15 22:06:47 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * this file tests all sorts of connecting to one single database.
       3             :  */
       4             : 
       5             : #include <stdlib.h>
       6             : #include <string.h>
       7             : #include <stdlib.h>
       8             : #include <stdio.h>
       9             : 
      10             : /* do not include regression.h */
      11             : 
      12             : int
      13           2 : main(void)
      14             : {
      15             : exec sql begin declare section;
      16             :     char db[200];
      17             :     char pw[200];
      18             : exec sql end declare section;
      19             : 
      20           2 :     ECPGdebug(1, stderr);
      21             : 
      22           2 :     exec sql connect to ecpg2_regression as main;
      23           2 :     exec sql alter user regress_ecpg_user1 ENCRYPTED PASSWORD 'connectpw';
      24           2 :     exec sql disconnect;  /* <-- "main" not specified */
      25             : 
      26           2 :     exec sql connect to ecpg2_regression@localhost as main;
      27           2 :     exec sql disconnect main;
      28             : 
      29           2 :     exec sql connect to @localhost as main user regress_ecpg_user2;
      30           2 :     exec sql disconnect main;
      31             : 
      32             :     /* exec sql connect to :@TEMP_PORT@ as main user regress_ecpg_user2;
      33             :     exec sql disconnect main; */
      34             : 
      35           2 :     exec sql connect to tcp:postgresql://localhost/ecpg2_regression user regress_ecpg_user1 identified by connectpw;
      36           2 :     exec sql disconnect;
      37             : 
      38           2 :     exec sql connect to tcp:postgresql://localhost/ user regress_ecpg_user2;
      39           2 :     exec sql disconnect;
      40             : 
      41           2 :     strcpy(pw, "connectpw");
      42           2 :     strcpy(db, "tcp:postgresql://localhost/ecpg2_regression");
      43           2 :     exec sql connect to :db user regress_ecpg_user1 using :pw;
      44           2 :     exec sql disconnect;
      45             : 
      46           2 :     exec sql connect to unix:postgresql://localhost/ecpg2_regression user regress_ecpg_user1 using "connectpw";
      47           2 :     exec sql disconnect;
      48             : 
      49           2 :     exec sql connect to unix:postgresql://localhost/ecpg2_regression?connect_timeout=14 user regress_ecpg_user1;
      50           2 :     exec sql disconnect;
      51             : 
      52             :     /* wrong db */
      53           2 :     exec sql connect to tcp:postgresql://localhost/nonexistent user regress_ecpg_user1 identified by connectpw;
      54           2 :     exec sql disconnect;
      55             : 
      56             :     /* wrong port */
      57           2 :     exec sql connect to tcp:postgresql://127.0.0.1:20/ecpg2_regression user regress_ecpg_user1 identified by connectpw;
      58             :     /* no disconnect necessary */
      59             : 
      60             :     /* wrong password */
      61           2 :     exec sql connect to unix:postgresql://localhost/ecpg2_regression user regress_ecpg_user1 identified by "wrongpw";
      62             :     /* no disconnect necessary */
      63             : 
      64           2 :     return 0;
      65             : }

Generated by: LCOV version 1.13